opentui-tex[community]

OpenTUI TeX

OpenTUI TeX renders TeX math inside an OpenTUI application. A formula joins the renderable tree like any box or text: give it \sum_{i=1}^{n} i^2 and the terminal shows selectable text cells:

  n
  ∑   i²
i = 1

Two backends supply different output. The Unicode backend parses a bounded subset of TeX math and lays out fractions, roots, scripts, accents, matrices, and cases as terminal cells. The output stays selectable text, and the backend has no native dependencies. The optional native package, @simonklee/opentui-tex-native, renders formulas as images (Kitty, Sixel, or block cells) through a prebuilt shared library: MicroTeX layout with real Latin Modern Math glyphs, at the cost of a native runtime dependency.

React and Solid apps register a <tex> element once and pass the formula as a prop. A streaming option keeps a Unicode preview updated while a formula is still incomplete, so an editor can render as the user types.

Both packages run on Bun and Node.js. Prebuilt native libraries cover x64 and arm64 on macOS, Windows, Linux glibc, and Linux musl; native rendering on Node.js needs the experimental FFI flags. Formulas are capped at 4,096 UTF-8 bytes.

The README documents both backends, the options, and the Node.js flags.