>99.5% KaTeX syntax coverage. LaTeX math renderer in pure Rust. No JavaScript, no WebView, no DOM. One Rust core → iOS, Android, Flutter, Web, PNG. C ABI · WASM · Server-side PNG/SVG.
翻訳待ち
Loading the full README.
Read the full README ↗简体中文 | English
KaTeX-compatible math rendering engine in pure Rust — no JavaScript, no WebView, no DOM.
One Rust core, one display list, every platform renders natively.
\frac{-b \pm \sqrt{b^2-4ac}}{2a} → iOS · Android · Flutter · React Native · Web · PNG · SVG · PDF
→ Live Demo — type LaTeX and compare RaTeX vs KaTeX side-by-side · → Support table — RaTeX vs KaTeX across all test formulas · → Web benchmark — head-to-head perf in the browser
Every major cross-platform math renderer today runs LaTeX through a browser or JavaScript engine — a hidden WebView eating 50–150 MB RAM, startup latency before the first formula, no offline guarantee. KaTeX is excellent on the web, but on every other surface — iOS, Android, Flutter, server-side, embedded — you're either hosting a WebView or shelling out to headless Chrome.
RaTeX is the same KaTeX-compatible math engine compiled to a portable Rust core, so the same renderer runs natively everywhere — and produces byte-identical output across every target.
| KaTeX | MathJax | RaTeX | |
|---|---|---|---|
| Runtime | JS (V8) | JS (V8) | Pure Rust |
| Surfaces it runs on | Web only* | Web only* | iOS · Android · Flutter · RN · Web · server · SVG · PDF |
| Mobile | WebView wrapper | WebView wrapper | Native |
| Server-side rendering | headless Chrome | mathjax-node | Single binary, no JS runtime |
| Output substrate | DOM (<span> tree) | DOM / SVG | Display list → Canvas / PNG / SVG / PDF |
| Memory | GC / heap | GC / heap | Predictable, no GC |
| Offline | Depends | Depends | Yes |
| Syntax coverage | 100% | ~100% | Aligned with KaTeX math syntax |
* Embeddable in non-web targets only by hosting a WebView or headless browser, which most native and server contexts can't tolerate.
On the web specifically, KaTeX has a decade of V8 JIT optimization behind it and remains the obvious choice for web-only projects. RaTeX's contribution isn't beating it on its home turf — it's being the only KaTeX-compatible engine that runs natively on every other surface, with pixel-identical output across all of them.
Math — Aligned with KaTeX’s math syntax: fractions, radicals, integrals, matrices, environments, stretchy delimiters, and more. The small set of DOM / trust-related extensions (e.g. \includegraphics, \htmlClass, …) is documented under KaTeX differences (commands & DOM) below.
Chemistry — full mhchem support via \ce and \pu:
\ce{H2SO4 + 2NaOH -> Na2SO4 + 2H2O}
\ce{Fe^{2+} + 2e- -> Fe}
\pu{1.5e-3 mol//L}
Physics units — \pu for value + unit expressions following IUPAC conventions.
Centered relation negation — \centernot\implies, \centernot{\impliedby}, and \centernot{\iff} center the negation slash over the entire argument and retain relation spacing (centernot package semantics).
Feynman slash notation — \slashed{p} and \slashed{\partial}, with scripts and font commands.
Proof trees — bussproofs-style prooftree for inference rules and sequent calculi:
\begin{prooftree}
\AxiomC{A \fCenter B}
\LeftLabel{cut}
\RightLabel{\alpha}
\UnaryInfC{C \fCenter D}
\end{prooftree}
Supported commands include \AxiomC / \AXC, unary through quinary inference commands (\UnaryInfC, \BinaryInfC, … and abbreviations such as \UIC, \BIC, \TIC), \LeftLabel / \RightLabel (\LL / \RL), \solidLine / \singleLine, \dashedLine, \noLine, the corresponding \always*Line defaults, \rootAtTop / \rootAtBottom, \alwaysRootAtTop / \alwaysRootAtBottom, and \fCenter.
Not yet implemented from bussproofs: \InsertBetweenHyps, \ScoreTree, \Cell, and \noCell. Proof-tree golden references use MathJax’s bussproofs extension because KaTeX does not implement prooftree.
These are the command-level gaps vs KaTeX (including trust-style HTML). Typical math and mhchem inputs are aligned with KaTeX. Some formulas still score below 1.0 in the support table or golden ink comparison due to layout/metrics/rasterization vs reference PNGs — that is not the same as “missing syntax” in the table below.
| KaTeX input | Notes |
|---|---|
\includegraphics[…]{…} | Not supported: parser has no handler (undefined control sequence). |
\htmlClass, \htmlData, \htmlId | Not equivalent: expanded as macros that drop the first argument’s class / data-* / id and keep only the second-argument body (unlike KaTeX trusted DOM attributes). |
\htmlStyle{…}{…} | Partial: simple inline styling may work on Web/Canvas paths; behavior may still differ from KaTeX’s DOM-based HTML extension. |
| Platform | How | Status |
|---|---|---|
| iOS | XCFramework + Swift / CoreGraphics | Out of the box |
| Android | JNI + Kotlin + Canvas · AAR | Out of the box |
| Flutter | Dart FFI + CustomPainter | Out of the box |
| React Native | Native module + C ABI · iOS/Android views | Out of the box |
| Compose Multiplatform | Kotlin Multiplatform + Compose Canvas · Android / iOS / JVM Desktop | Via RaTeX-CMP |
| Web | WASM → Canvas 2D · <ratex-formula> Web Component | Out of the box |
| Server / CI | ratex-render → tiny-skia PNG rasterizer | Out of the box |
| SVG | ratex-svg → self-contained vector SVG | Out of the box |
ratex-pdf → vector PDF with embedded KaTeX fonts | Out of the box |
From the demo apps in demo/screenshots/.
This is the beginning of the README. Read the rest at the original. Read the full README ↗