Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LTX

An extremely fast LaTeX project manager, written in Rust.

LTX scaffolds structured projects, lints your source, drives tectonic (and pdflatex/xelatex/lualatex), and gets out of your way — built for people who’d rather be writing than babysitting a build.

Status: pre-1.0. The CLI surface is stabilizing; expect minor breaking changes between minor versions until 1.0.


Why LTX?

Most LaTeX workflows are stitched together from shell scripts, latexmk, and muscle memory. LTX treats your document the way a modern build tool treats a codebase:

  • Correct by construction — one ltx.toml describes your project; builds behave the same on your machine, your co-author’s machine, and in CI.
  • Fast — a Rust core and a native engine mean large multi-file papers compile quickly, without a full TeX distribution installed.
  • Predictable — the diagnostics pipeline gives you one consistent, source-spanning report for syntax and configuration problems.

Architecture

LTX is a Rust workspace composed of seven crates. Each crate owns its domain, and errors are defined in the crate that produces them — never centralized.

CrateRole
ltx_utilsLow-level filesystem helpers (create_dir, write_file, resolve_main_file)
ltx_diagnosticsPure diagnostic infrastructure — spans, source maps, miette rendering (defines no domain errors)
ltx_lexerByte-level tokenizer — converts .tex source into a stream of typed tokens
ltx_parserRecursive-descent parser — consumes the token stream and produces an AST
ltx_configManifest model + validation + scaffolding — reads ltx.toml, generates project layouts
ltx_compilerCompilation orchestration — dispatches to an engine (currently tectonic)
ltx_cliBinary entry point — subcommand dispatch, user-facing output, exit codes

The pipeline

Source text flows through the toolchain in this order:

  .tex source
       │
       ▼
   LtxLexer          ──► TokenStream (LtxToken + LtxSpan)
       │
       ▼
   LtxParser          ──► AST (Document, Command, Environment, …)
       │
       ▼
   ParserErrorHandler ──► LtxDiagnosticSink (absorbs lexer + parser diagnostics)
       │
       ▼
   miette renderer    ──► Terminal output
  1. Lexer scans raw bytes, applies TeX catcode rules, and emits LtxTokens with source spans. Problems are recorded by its own LexerErrorHandler.
  2. Parser consumes the token stream via TokenStream (peek/bump/checkpoint/rewind), builds the AST, and reports through its own ParserErrorHandler, which absorbs the lexer’s diagnostics on construction.
  3. Diagnostics accumulate in an LtxDiagnosticSink and render with miette for rich terminal output or serialize to JSON.

Error codes

Every diagnostic code is namespaced by the phase that owns it — 30 total:

NamespaceCountRange
LTX::LEXER::E0xx11Tokenization
LTX::PARSER::E0xx6Structural parsing
LTX::CONFIG::E0xx8Manifest / scaffolding
LTX::COMPILER::E0xx / W0xx5Compilation

Run ltx code to list them, filtered by phase (--lexer, --parser, --config, --compiler) or severity (-e, -w).

Quick start

# Scaffold a new project
ltx new my-paper
cd my-paper

# Check for errors
ltx check main.tex

# Build a PDF (tectonic is bundled; no TeX distribution needed)
ltx build

# List diagnostic codes
ltx code

Documentation pages