Accumath

Open source

latex-rust

Pure-Rust LaTeX math renderer to SVG, PNG, or egui. Free and open source, built by the Accumath team for the community.

About

Pure-Rust LaTeX math renderer. It parses math into a typed syntax tree, lays it out with exact rational dimensions, and draws it as SVG, PNG, or egui shapes using the embedded STIX Two Math font. No JavaScript or webview runtime; one small pure-Rust required dependency (ttf-parser). Minimum Rust version 1.76.

Current version 2.1.0 · License MIT OR Apache-2.0 (embedded STIX Two Math font: SIL OFL 1.1)

Version 1.0.5 is available for 1.x users. It is a drop-in update from 1.0.4 with the depth limit for nested input, the 2.0 rendering fixes that need no API change, and the egui fix from 2.0.1.

latex-rust on crates.io · Source on GitHub

Built and tested (1–18)

103 tests pass on version 2.0.1, backed by 534 gold records and a check of all 476 commands in the symbol catalog. The tests also pass on the stated minimum Rust version, 1.76. An item is listed here only when it is built, has tests, and those tests pass.

  1. 1Parse LaTeX math into a typed syntax tree (fractions, roots, scripts, delimiters, matrices, operators, accents, environments, colors)
  2. 2Inline and display math delimiters ($…$, $$…$$, \(…\), \[…\]) and % comments
  3. 3All 476 commands in the published symbol catalog (Greek, AMS, arrows, relations, operators, and more)
  4. 4Math font styles (\mathbb, \mathcal, \mathfrak, \mathscr, \mathbf, \mathit, \mathrm, \mathsf, \mathtt)
  5. 5TeX math-style layout (display, text, script, and scriptscript styles, cramped styles, TeX inter-atom spacing)
  6. 6Exact rational layout arithmetic with no hardware floats
  7. 7Script glyphs drawn at the correct script and scriptscript sizes
  8. 8Accents and decorations (hats, bars, vectors, dots, wide accents, over and under braces and arrows, cancel)
  9. 9Multi-line environments (aligned, align with numbering and tags, gather, multline, equation, cases, array, label and ref)
  10. 10Matrices (matrix, pmatrix, bmatrix, vmatrix, Vmatrix, Bmatrix)
  11. 11Color (\textcolor, \color, \colorbox, \fcolorbox, \definecolor in rgb, RGB, HTML, cmyk, and gray, plus named and dvips colors)
  12. 12SVG output
  13. 13PNG output with selectable DPI and background (optional feature)
  14. 14egui shape output with HiDPI scaling (optional feature)
  15. 15Clear errors instead of wrong output for unknown commands, malformed input, and unsupported environments
  16. 16Protection against deeply nested input (depth limit, default 32, adjustable)
  17. 17Embedded STIX Two Math font metrics
  18. 18Documented API examples that compile and run

Still to build (19–20)

  1. 19Layout checked against output from real TeX
  2. 20Test runs on Windows, macOS, Android, and iOS

All open-source projects Buy a pre-release Accumath license — $25+