Ratatex is a Rust library that renders TeX display math as high-resolution, scrollable PNGs inside Ratatui terminal UIs using in-process parsing and Kitty graphics placeholders.

Stars

7

7-day growth

No data

Forks

1

Open issues

0

License

MIT

Last updated

2026-07-29

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It delivers TeX-quality math rendering directly in the terminal without requiring a TeX installation, uses non-blocking in-process rendering with a content-addressed cache, and supports streaming Markdown and copyable LaTeX fallback.

Who it is for

  • Terminal UI developers using Ratatui
  • Researchers and data scientists who use math in terminals
  • Developers building AI chat or streaming math applications
  • Maintainers of terminal-based scientific or educational tools

Use cases

  • Render equations in a terminal-based AI assistant or chat interface
  • Embed math in a TUI scientific notebook or REPL
  • Display formulas in a live streaming Markdown renderer
  • Provide copyable LaTeX math in terminal selection workflows

Strengths

  • No external TeX installation or subprocess needed; all rendering is in-process using RaTeX and embedded KaTeX fonts
  • Non-blocking API with content-addressed PNG cache and optional update callback
  • Streaming Markdown support: renders incomplete math expressions gradually using a healing helper
  • Seamless scrolling and clipping via Kitty Unicode placeholders, plus copyable source fallback

Considerations

  • Requires a terminal that implements Kitty graphics protocol (e.g., Ghostty, Kitty, WezTerm, recent Konsole)
  • Only supports a KaTeX/AMS subset of LaTeX; no arbitrary TeX packages or fallback to system TeX
  • Scrolling behavior depends on terminal support for Unicode placeholders and graphics passthrough (e.g., tmux configuration needed)

README quick start

Ratatex

TeX-quality display math that scrolls with your Ratatui UI.

Nanocodex demo · Try it · Embed it · Streaming · Selection · Scrolling

https://github.com/user-attachments/assets/9012dcc3-b7d2-44d0-acdf-c94cc73ed5f7

A live Nanocodex low-reasoning run: render TeX, click back to source, and drag-copy the original LaTeX.

Ratatex turns Markdown display math into cell-aligned PNGs on bounded background workers:

Markdown display math
    → RaTeX parse + TeX layout in-process
    → embedded KaTeX fonts + tiny-skia at 3× resolution
    → antialiasing, padding, and cell alignment
    → content-addressed PNG cache
    → Kitty virtual placement + Unicode-placeholder cells

Rendering uses the open-source RaTeX parser, layout engine, embedded fonts, and rasterizer entirely in-process. Ratatex never invokes a system TeX installation, writes DVI, or starts a rendering subprocess. Unsupported expressions return a typed failure so the host application can keep its text representation.

The placeholder cells live in the normal Ratatui buffer. Equations therefore scroll and clip with the surrounding text instead of behaving like cursor-positioned overlays.

Install

cargo add ratatex

Requirements

  • A terminal implementing Kitty graphics Unicode placeholders.
  • Ratatui 0.29.
  • No TeX distribution or external rendering programs.

Ghostty, Kitty, WezTerm, and recent Konsole releases implement the graphics protocol. When running inside tmux, enable graphics passthrough:

set -g allow-passthrough on

Try it

From a compatible terminal:

cargo run --example demo

Press q, Esc, or Ctrl-C to leave the demo.

Embed it

Query the terminal after entering the alternate screen and before starting a competing input reader. Build one renderer for the application, not one per formula:

use std::{io::Write, time::Duration};

use ratatex::{FormulaState, FormulaWidget, Ratatex, TerminalProfile};

Description

TeX-quality display math for Ratatui with Kitty Unicode placeholders

Related repositories

Similar projects matched by category, topics, and programming language.

l0ng-ai
Featured
l0ng-ai GitHub avatar

tty7

tty7 is a fast, GPU-accelerated terminal workbench with persistent sessions, built-in input tools, SSH support, and coding agent awareness.

Developer ToolsCLI & Terminal
359
steelbrain
Featured
steelbrain GitHub avatar

reims-vgpu

reims-vgpu is an experimental virtual GPU for macOS guests that uses QEMU to decode the guest's GPU command stream and execute it through Metal or Vulkan, leveraging the built-in AppleParavirtGPU driver without requiring custom kexts.

Desktop Apps
143
m-novotny
Featured
m-novotny GitHub avatar

memguard-rs

A Rust library that provides secure memory handling primitives including zeroization on drop, memory locking, constant-time comparison, and compile-time guarded regions, with zero dependencies and no_std support.

Embedded & IoTSecurity
131