latex_kit 0.1.4 copy "latex_kit: ^0.1.4" to clipboard
latex_kit: ^0.1.4 copied to clipboard

A lightweight, pure Dart Flutter package for rendering LaTeX symbols.

  • Pure Dart: Compiles natively for all platforms without relying on WebViews or native platform channels.

Online Demo #

Example #

Render LaTeX #

import 'package:latex_kit/latex_kit.dart';

Latex(
  r'\int_{a}^{b} f(x)\,dx',
  config: LatexConfig(fontSize: 20),
)

Interactive LaTeX Editor #

import 'package:latex_kit/latex_kit.dart';
import 'package:latex_kit/render/editor/editor_state.dart';

LatexEditor(
  editorState: EditorState(
    r'\int_{a}^{b} f(x)\,dx',
  ),
)

Auto Wrap #

import 'package:latex_kit/latex_kit.dart';

LatexAutoWrap(
  latex: r'x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 = y_1 + y_2 + y_3 + y_4',
)

🚀 Quick Start #

Here is how easy it is to combine themes, highlights, and interactions into a single widget:

Latex(
  latex: 'E = mc^2 \\href{[https://example.com](https://example.com)}{[Learn More]}',
  config: LatexConfig(
    theme: LatexTheme.auto(), // Automatically adapts to system theme
    onHyperlinkClick: (url) => debugPrint('Clicked: $url'),
    highlight: HighlightConfig(
      ranges: [
        // Highlight by pattern
        HighlightRange(
          pattern: 'mc', 
          color: Color(0x4400AAFF),
          borderColor: Color(0xFF0088FF),
        ),
        // Or highlight by node index
        HighlightRange(
          nodeIndices: IntRange(0, 2),
          color: Color(0x33FF6600),
        ),
      ],
    ),
  ),
)

LaTeX Support (450+ Symbols) #

Mathematical Expressions — Fractions, Roots, Binomials, Superscripts & Subscripts

Supports \frac, \dfrac, \tfrac, \cfrac, \genfrac, \splitfrac, \splitdfrac, \binom, \tbinom, \dbinom, along with TeX infix forms such as \over, \atop, \choose, and \above. Square roots, superscripts, and subscripts are also supported.

Symbol System (130+) — Greek Letters, Operators, Arrows, AMS Symbols
  • Greek Letters: Complete lowercase (α–ω, including \omicron), uppercase (Γ–Ω), KaTeX-style uppercase aliases (\Alpha, \Beta, \Epsilon, \Omicron), and variants (\epsilon/\varepsilon, \theta/\vartheta, \phi/\varphi, \varGamma\varOmega, etc.).
  • Operators: +, -, \times, \div, \pm, \mp, \cdot, \oplus, \otimes, and more.
  • Relations: =, \neq, <, >, \leq, \geq, \approx, \equiv, \sim, \coloneqq, \eqqcolon, etc.
  • Set Theory: \in, \notin, \subset, \cup, \cap, \emptyset, \mathbb{R}, etc.
  • Logic: \land, \lor, \neg, \Rightarrow, \Leftrightarrow, \forall, \exists.
  • Arrows: \to, \rightarrow, \leftarrow, \leftrightarrow, \Rightarrow, \hookrightarrow, harpoon arrows, and more.
  • Ellipsis: \ldots, \cdots, \vdots, \ddots, \dots (context-aware).
  • Negated Symbols: \not=, \notin, \nleq, \ngeq, \ncong, \nmid, and 30+ AMS negated relation symbols.
  • Additional AMS Symbols: \checkmark, \complement, \blacksquare, \aleph, \measuredangle, geometric symbols, double-headed arrows, and more.
Large Operators (28) — Summation, Integrals, Limits, Modulo
  • Summation & Integrals: \sum, \prod, \int, \oint, \iint, \iiint, \bigcup, \bigcap, \bigvee, \bigwedge, \coprod, \bigoplus, \bigotimes, \bigsqcup, \bigodot, \biguplus.
  • Limits: \lim, \max, \min, \sup, \inf, \limsup, \liminf.
  • Custom Operators: \operatorname, \operatorname*, \DeclareMathOperator, \mathop.
  • Multi-line Subscripts: \substack.
  • Modulo: \bmod, \pmod, \mod.
Matrices — Standard, Starred & Compact Matrix Environments

Supports matrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix, smallmatrix, mathtools starred variants with [l|c|r] alignment, as well as array and subarray.

Delimiters & Brackets — Automatic Scaling & Manual Sizes
  • Automatic sizing with \left...\right and \middle.
  • Asymmetric delimiters such as \left.\right| and \left\{\right..
  • Manual sizing using \big, \Big, \bigg, \Bigg and variants (\bigl, \bigr, \bigm).
Decorations (42+) — Accents, Cancellation, Stretchy Arrows, Braces
  • Accents: \widecheck, \overparen, \underparen, and standard accents.
  • Braces: \overbrace, \underbrace, \overbracket, \underbracket.
  • Arrow Decorations: \overrightarrow, \overleftarrow, \overleftrightarrow, \underleftarrow, \underrightarrow.
  • Cancellation: \cancel, \bcancel, \xcancel.
  • Stretchy Arrows: \xrightarrow, \xleftarrow, \xhookrightarrow, \xhookleftarrow, \xRightarrow, \xLeftarrow, \xLeftrightarrow, \xmapsto, \xlongequal.
  • Stacking: \overset, \underset, \stackrel.
Font Styles (17)

Supports \mathbf, \mathit, \mathrm, \mathsf, \mathtt, \mathbb, \mathfrak, \mathcal, \mathscr, \boldsymbol, \bm, \text, \mbox, \textnormal, \textup, \textmd, \textsc, \textsl, \emph, and Unicode-math style aliases.

Font Sizes (10)

\tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge, \Huge

Math Styles

Supports \displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle, inline math ($...$), and display math ($$...$$).

Environments (21) — Alignment, Cases, Matrices, Tables
  • Equation: equation(*), displaymath
  • Alignment: align(*), aligned, flalign(*), alignat(*), alignedat
  • Centered: gather(*), gathered
  • Cases: cases, dcases, rcases and starred variants
  • Multi-line: split, multline(*)
  • Others: eqnarray(*), subequations, tabular
  • Line Control & Numbering: \\, \cr, \intertext, \shortintertext, \notag, \nonumber, \tag, \label, \ref, \eqref
Spacing Control

Supports standard mathematical spacing, \hspace, \kern, \mkern, \allowbreak, and common escaped special characters.

Colors & Backgrounds
  • Text Colors: \color, \textcolor
  • Background Colors: \colorbox, \fcolorbox
Chemistry (13) — mhchem

Supports \ce, \bond, and \pu, including molecules, ions, isotopes, reaction arrows, and chemical equations.

Special Effects & Layout (17)
  • Boxes: \boxed, \fbox
  • Enclosures: \enclose, \circled
  • Supported Notations: box, roundedbox, circle, left, right, top, bottom, updiagonalstrike, downdiagonalstrike, verticalstrike, horizontalstrike
  • Supported Attributes: mathcolor, mathbackground
  • Phantoms: \phantom, \smash, \vphantom, \hphantom, \mathstrut
  • Zero-width Layout: \mathclap, \mathllap, \mathrlap
  • TeX Layout: \clap, \llap, \rlap, \raisebox, \rule
  • Mathtools: \Aboxed, \MoveEqLeft, \splitfrac, \splitdfrac, \DeclarePairedDelimiter
Physics & SI Units
  • Derivatives: \dv, \pdv
  • Dirac Notation: \bra, \ket, \braket, \comm, \anticomm, \eval, \vb, \va, \abs, \norm
  • SI Units: \SI, \si, \qty, \unit, \numrange, \qtyrange, \ang
Advanced Annotations (6)
  • Hyperlinks: \href, \url
  • Side Sets: \sideset
  • Prescripts: \prescript
  • Tensor Indices: \tensor, \indices
Custom Commands & Macros (9)

Supports \newcommand, \renewcommand, \def, \newenvironment, \renewenvironment, and \DeclarePairedDelimiter.

Sectioning Commands

\section, \subsection, \subsubsection, \paragraph, \subparagraph (including starred variants).

RTL Text Support
  • Commands: \RLE, \LRE, \textarabic, \texthebrew
  • Environments: RTL, LTR
  • Supports nested RTL/LTR rendering.
Labels & References

Supports \label, \ref, \eqref, \tag, and \tag*.

Error Handling
  • Unknown commands are rendered with an error color instead of being silently ignored.
  • parseWithDiagnostics() provides structured diagnostics with eight error categories and severity filtering.

⚡ Benchmark & Comparison #

Why choose latex_kit over legacy alternatives?

Feature flutter_math_fork latex_kit
Compiled Dart Size ~2 MB ~1 MB (~50% smaller)
Symbol Coverage Standard Extensive (450+ Symbols)
Auto Line-Wrapping ❌ No ✅ Yes
Native Canvas Editor ❌ No ✅ Yes

Dependencies & Acknowledgements #

latex_kit utilizes or derives code from the following packages:

  • glyph_path - Used exclusively for precise text measurement. It allows the renderer to extract the exact ink boundaries of the KaTeX fonts instead of relying on standard text line boxes, ensuring pixel-perfect math layouts

  • KaTeX - The original web library whose font sets and spacing rules were adapted for this Flutter package.

If you find any issues, kindly let me know. #

1
likes
0
points
606
downloads

Publisher

verified publishertokeyan.online

Weekly Downloads

A lightweight, pure Dart Flutter package for rendering LaTeX symbols.

Homepage

License

unknown (license)

Dependencies

flutter, glyph_path

More

Packages that depend on latex_kit