HenryXiaoYang / realtime-tex
git clone https://github.com/HenryXiaoYang/realtime-tex.git
v0.0.5 · 1d ago
Realtime TeX: re-typesets only the paragraph you edit in ~1 ms with an unmodified LuaTeX. Exact, embeddable.
—
stars, 24h
—
stars, 7 days
+233
stars, 30 days · #1,125
233
★ total
21
forks · 2 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguageRust
LicenseMIT
Created2026-10-07 (13d ago)
Last pushtoday
Watchers1
OwnerUser
GitHub topics
c-apieditorincremental-compilationlatexlibrarylive-previewlualatexluatexpdfreal-timerusttextexlivetypesettingvscode
Links
README excerpt
# realtime-tex (rtex) English | 简体中文 **See your LaTeX document update as you type, in about a millisecond, without leaving LuaLaTeX.** rtex is a library for editors. When you type, it re-typesets only the paragraph you are editing, using a LuaLaTeX process that has already loaded your preamble, and hands the editor the new lines to draw. A full compile runs in the background and takes care of what really is global: page breaks, floats, the table of contents, references and bibliographies. The result is exactly what LuaLaTeX produces: the same line breaks, the same glyphs, at the same positions to 1/65536 pt. rtex uses an unmodified LuaTeX from TeX Live, and exported PDFs are identical to a normal LuaLaTeX build. [code] The approach follows Clemens Lode, *Real-Time LuaTeX: Recompiling Large Documents in 1 ms* (TUG 2026). ## Use it in VS Code The quickest way to use rtex is the **Realtime TeX Live Preview** extension for VS Code. It shows a live preview next to your editor and installs rtex (and, if needed, a minimal TeX Live) for you on first use. Open a `.tex` file, click the preview icon in the editor title bar (or press Ctrl+Alt+V, Cmd+Alt+V on a Mac), and start typing. It runs rtex natively on Linux, macOS and Windows, and downloads the prebuilt engine for your platform. The rest of this page is about rtex itself: the library the extension is built on. ## How fast Time from keystroke to the updated paragraph in the editor's hands (median of 300 edits, on a 4-vCPU cloud VM; a laptop is usually faster). Full benchmarks. | Paragraph | 10-page document | 100 pages | 300 pages | |---|---|---|---| | one line | 0.50 ms | 0.48 ms | 0.61 ms | | four lines | 1.04 ms | 1.10 ms | 1.18 ms | | ten lines | — | 2.39 ms | 1.94 ms | | a list, a figure, a table, display math | 1.4–1.9 ms | 1.5–1.7 ms | | Document length does not matter, only the paragraph does. The font setup matters too. With fontspec's default OpenType shaping, a long paragraph takes up to 4–5× longer than with TFM fonts or `Renderer=Basic` (why). Typed into the same document, a paragraph updates in 1.3–1.6 ms with rtex, 18 ms (10 pages) to 414 ms (300 pages) with Typst 0.15.1, and a full LuaLaTeX run takes 0.5–1.7 s. That full run is what Overleaf repeats on every recompile (comparison). ## What updates live Text, math (inline and display, `align` and friends), references and citations, lists, theorems, figures and tables, headings, footnote marks, your own macros and environments, and most packages. When rtex cannot prove that a live result would be exact, it says why, and the paragraph appears with the next background pass instead. That covers preamble edits, the table of contents, margin notes, and text whose output depends on page state. Full list. ## Install **Prebuilt binaries** for Linux (x86_64, arm64), macOS (Apple silicon, Intel) and Windows (x86_64) are attached to every release. Each archive holds the `rtex` command, the C library and header, and rtex's TeX support files. Unpack