Fork me on GitHub

Pure-Go TeX that runs the real LaTeX classes.
In Go and in the browser, no TeXLive.

go-tex is a pure-Go (CGO_ENABLED=0) TeX effort. Its engine is a faithful re-implementation of TeX, and on top of it it loads and runs the genuine LaTeX classes: \documentclass{article}, {report} and {book} execute the real, embedded .cls files (LPPL, verbatim) — not an emulation. They also run in the browser through js/wasm, with no server.

7 capability areas7 repositoriesCGO=0 no TeXLive
main.go
out, _ := engine.New().Run(`\def\twice#1{#1#1}\message{\twice{\twice A}}`)
// out == "AAAA"
7 repositories — pure Go, no cgo, native and js/wasm
Why go-tex

Genuine LaTeX classes, in pure Go.

The engine is a faithful re-implementation of TeX — the category-code mouth and gullet, a scaled-point stomach with Knuth–Plass line breaking and a cost-based page builder, \halign tables, math, OpenType fonts, and PDF/SVG output. The class files are embedded and the resolver needs no filesystem, so the real classes also run in the browser — genuine LaTeX class rendering client-side, with no TeXLive and no server.

What the engine offers

7 areas, held to objective oracles.

Real base classes

article, report and book load and run the genuine embedded LaTeX .cls files — numbered title, dotted TOC, numbered sections and chapters, figure and table captions, lists, math.

Faithful engine

Category-code mouth and gullet, a scaled-point stomach with Knuth–Plass line breaking, a cost-based page builder that keeps TeX’s page_total and page_depth apart — the depth of a page’s last line is capped at \maxdepth and not charged against the goal, so a page that fills to exactly \textheight is accepted — and \halign tables.

Math and fonts

Math via go-tex/math (vector output); OpenType fonts with a built-in default font, kerning and ligatures — runs with no assets, and a full family (roman, bold, italic, slanted, typewriter, sans) when one is given.

PDF and SVG output

Embedded-subset-font PDF with selectable text, and self-contained SVG pages carrying a source map for click-to-line.

In the browser

A self-contained js/wasm build renders real LaTeX classes client-side — no TeXLive, no server.

Safe on untrusted input

A .tex is a program, and the playground runs whatever you paste. A document compiled by the engine cannot run a process, cannot write a file, cannot read one outside the search roots (TeX Live’s openin_any=p, with GOTEX_READ_ANY=1 as a named opt-out), and cannot exhaust memory or run forever: one paragraph is capped at 200 000 nodes.

Held to fidelity

A byte-exact conformance ratchet plus a whole-document prose check against a real LaTeX engine (tectonic): on 154 real arXiv papers the median is 101% of the reference’s prose words, with 10 of them below 95%. Pagination lands on the reference exactly for 36 of the 154 at v0.263.0, and the open figure is the signed bias of +72 pages — a one-column phenomenon, tracked as engine#622.

Scope

Real-LaTeX fidelity, not a claim of TeXLive parity.

The engine loads and runs the standard base classes — article, report, book and amsart as real embedded files — and any resolvable .cls/.sty runs as real TeX macros. Heavy drawing (tikz/pgf) is gated and still in bring-up, biblatex is partly supported, PDF figures need the pdfrender module, and floats typeset inline unless placement is enabled. Every supported feature — and every remaining gap — is listed in the capability reference.

Repositories

What is here.

engine

engine

The pure-Go TeX engine: a faithful mouth and gullet, a scaled-point stomach with Knuth–Plass line breaking and a cost-based page builder that keeps page_total and page_depth apart, \halign tables, e-TeX, math, OpenType fonts, PDF and SVG output, and the real embedded LaTeX classes (article, report, book, amsart), native and js/wasm.

math

library

Pure-Go TeX math-mode typesetter to self-contained SVG, through the OpenType MATH table: fractions, radicals, matrices, big operators with limits, stretchy delimiters, scripts. Ships STIX Two Math; wasm-ready.

pdfrender

library

Pure-Go (CGO=0) rasteriser for PDF figures. Plugs into the engine's RasterizePDF seam so \includegraphics{fig.pdf} renders pixels instead of a framed placeholder. A separate module, to keep the engine and wasm core free of a heavy dependency.

texmf

library

On-demand TeX support-tree fetcher for machines with no TeX distribution. Redistributes nothing: it fetches pinned, SHA-256-verified upstream macro source into a user cache and supplies Tree.Resolve to the engine. Never fetches speculatively.

tex

library

Pure-Go (CGO=0) processor for a subset of LaTeX documents: macro expansion, structure and math to semantic HTML rather than to a page. Where the engine typesets, this one reads — a foundation for full LaTeX on the HTML path.

docs

site

The documentation site (MkDocs Material + mike): every supported feature, and every remaining gap, in the capability reference. Source →

brand

assets

Logos and icons for the organization.

Real LaTeX classes, with no TeXLive and no server.

Pure Go, CGO_ENABLED=0, native and in the browser. Safe on untrusted input: a compiled document cannot run a process, write a file, or read one outside the search roots.

Read the source on GitHub →