Math equations (KaTeX)
vyuh_document_katex adds pure-Dart LaTeX math typesetting powered by katex_core — no WebView, no JavaScript runtime, and full Microsoft Word OMML (<m:oMath>) round-trip.
- Optional heavy plugin: Shipped as a separate package pair so apps without math pay zero bundle cost
- Pure-Dart package:
package:vyuh_document_katex/vyuh_document_katex.dart - Flutter package:
package:vyuh_document_katex_flutter/vyuh_document_katex_flutter.dart - Action namespace:
KatexActions(insertInline,insertDisplay,edit)
Installation
yaml
dependencies:
vyuh_document_katex:
hosted: https://pub.vyuh.tech
version: ^0.90.0
vyuh_document_katex_flutter:
hosted: https://pub.vyuh.tech
version: ^0.90.0sh
flutter pub add vyuh_document_katex vyuh_document_katex_flutter --hosted-url https://pub.vyuh.techQuick example
dart
import 'package:vyuh_document_flutter/editor.dart';
import 'package:vyuh_document_katex_flutter/vyuh_document_katex_flutter.dart';
final config = documentConfiguration.withElements([Equation.element]);
final controller = DocumentEditorController(
document: Document.of(config, [
Paragraph('Euler identity:'),
Equation(r'e^{i\pi} + 1 = 0'),
]),
extensions: [
...DocumentEditorElements.defaults,
const KatexDocumentExtension(),
],
);What you can configure
| Capability | Details |
|---|---|
| Display vs. inline math | Insert standalone centered display equations (Equation) or inline equations flowing smoothly inside paragraphs |
| Live LaTeX editor popover | Click any equation to edit its LaTeX source with live preview and syntax error feedback |
| Pure-Dart layout & PDF | Uses the same resolved vector layout in Flutter and PDF — crisp at any zoom level |
| Localization | Customize UI strings via KatexDocumentLocalizations |
| Markdown math syntax | Opt in to $...$ and $$...$$ round-trip via katex_markdown_extension.dart |
Actions & commands
| Action ID / Command | Effect |
|---|---|
KatexActions.insertInline | Insert an inline LaTeX math atom at the caret |
KatexActions.insertDisplay | Insert a block-level display equation |
KatexActions.edit | Open the live LaTeX editor for the selected equation |
SetEquation | Pure-Dart command updating an equation's LaTeX source |
Restricting usage
- Keep bundle lean: Simply omit
vyuh_document_katexwhen math is not needed. - Inline equations only: Include
KatexActions.insertInlinein yourActionGroupand omit/gateKatexActions.insertDisplay.
See the full KaTeX coverage matrix.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Bidirectional Word OMML (<m:oMath> / <m:oMathPara>) | Exact vector KaTeX layout & math fonts | MathML / KaTeX-annotated HTML | $...$ inline and $$...$$ display math |