Rust · WASM · Native

TeX-quality math from one Rust layout core

RaTeX parses LaTeX math, applies TeX-style rules, and emits a flat display list for CoreGraphics, Skia, Canvas 2D, or your own vector backend—identical output from native FFI and WebAssembly.

Alignment: RaTeX is built to match KaTeX where it matters: CI runs large golden suites with pixel diffs against reference images, and on that corpus output is broadly comparable to KaTeX. The support table walks the full golden list side-by-side with KaTeX. Where it fits: for math inside a normal web page, KaTeX in the DOM remains a great default. RaTeX is aimed at native apps, servers, and embeds without a WebView—same engine from mobile to WASM.

Try it

INPUT.TEX

OUTPUT

Loading…

Packages

Integrate anywhere

Ready-to-use SDKs and WASM builds ship from the same Rust core: install from npm, Maven, pub.dev, or SPM—step-by-step in Get started. Server-side PNG and CLI are covered there too.

npm ratex-wasm / ratex-react-native · Maven io.github.erweixin:ratex-android · pub.dev ratex_flutter · iOS via SPM

When to reach for RaTeX

memory

Rust core

One layout engine, no GC in the hot path: predictable timing for mobile UIs, servers, and CI raster tests.

MEMORY_SAFE DISPLAY_LIST
devices

Ship everywhere

C ABI for Swift, Kotlin, Dart, … WASM for the web; tiny-skia or your own rasterizer—identical display lists.

WASM FFI
science

mhchem-style chemistry

Built-in \ce and \pu on the mhchem-compatible path—reaction arrows and physical units in the same pipeline as ordinary math.

MHCHEM LATEX_MATH

Try it in the browser

Golden-suite galleries

Browse the same LaTeX lines CI uses, rendered with RaTeX WASM on the page: Math, Chemistry, Physics. For side-by-side comparison with KaTeX, open the interactive demo; the full golden suite lives in the support table on the Demo page.

Why not a WebView stack?

In the browser, KaTeX and MathJax typically run as JavaScript against the DOM. For app shells that embed math via WebView, that still means shipping a browser stack. RaTeX keeps layout and rasterization in Rust for hosts that want to avoid that path.

Web stack comparison: RaTeX versus KaTeX and MathJax
RaTeX KaTeX (web) MathJax
Runtime Pure Rust JavaScript + DOM JavaScript + DOM
Mobile Native / WASM WebView WebView
Offline Yes Depends Depends
JS bundle (typical) 0 kB JS (core is WASM) ~280 kB ~500 kB
Memory model Predictable GC / heap GC / heap

RaTeX vs native math SDKs

Without a WebView, teams often reach for Swift, Objective-C, or Flutter libraries. Below is a high-level comparison with widely used open-source renderers—swiftMath (Swift), flutter_math_fork / flutter_math (Dart / Flutter), and iosMath (iOS)—on chemistry macros, portability, and engine shape. Third-party SDKs evolve independently; compare versions when you integrate.

RaTeX compared to swiftMath, flutter_math, and iosMath: mhchem support, cross-platform engine, and layout core performance characteristics
Capability RaTeX swiftMath flutter_math iosMath
mhchem \ce (chemistry) check_circle cancel cancel cancel
\pu / siunitx-style units check_circle cancel cancel cancel
Same engine: native FFI + WASM (web) check_circle cancel cancel cancel
Mobile + desktop from one Rust core check_circle cancel cancel cancel
TeX layout core in Rust (predictable hot path) check_circle cancel cancel cancel

*Performance depends on workload. Swift uses ARC; Dart uses a tracing GC—both differ from RaTeX's Rust core for the same "no browser" embedding story.

function

Ship scientific UI without embedding a browser engine