3.4 KiB
Executable File
TeX-compatible incremental core (route D)
Status: M0 architecture spike implemented in crates/texrra-tex-core.
The production v1 engine in src/rust_typeset remains the default and is kept as
a fallback while the TeX-compatible core grows.
Why route D
The v1 engine parses LaTeX into DocumentModel and lays it out with
hand-written algorithms. That gives true incremental preview, but it cannot be
page-identical for arbitrary .cls/.sty files: class files are TeX programs,
and their layout primitives (\vbox, \halign, \output, \twocolumn,
insertions, math lists, font metrics) are not executed.
Route D is a TeX-compatible execution/layout core designed for incremental operation from the start. It does not embed pdfTeX, XeTeX or Tectonic.
M0 scope (this spike)
crates/texrra-tex-core currently provides:
VerticalItem::{Box, Glue, Penalty}andVerticalBoxas the first vertical list model;Unit::paragraphas a placeholder for the future TeX paragraph builder;Engine::layoutthat builds pages with a simple page goal;Checkpointbefore every top-level unit, containing the completed-page count, used vertical space and current page items;Pagehashes derived from both vertical items and the contributing unit sources;Engine::editwhich restores the checkpoint before the edited unit, re-executes only the suffix, compares page hashes, and reportsrecomputed_pages;- serde round-trip for checkpoints.
M0 proves the incremental contract, not TeX compatibility. The paragraph builder, page builder, math, fonts and class execution are still ahead.
Target architecture
- Persistent TeX VM state: macros, registers, fonts, counters, output queue.
- Stable IDs for top-level units.
- Checkpoint at page boundaries plus unit boundaries.
- Dependency graph for labels, references, counters, TOC and citations.
- Dirty propagation: after a local edit, replay from the nearest checkpoint and stop at the first unchanged page hash.
- Float/footnote queues restored with the checkpoint.
Milestones
| Milestone | Content | Acceptance |
|---|---|---|
| M0 | vertical list, page builder, checkpoint, page hash, edit demo | edit on page 2 rebuilds only page 2 |
| M1 | TeX box/glue/penalty + paragraph builder (\par, \hsize, \parindent) |
line breaks match pdfTeX for test paragraphs |
| M2 | page builder + \output, \vsize, \topskip, footnotes, floats |
one-column article matches reference pages |
| M3 | \halign, \omit, \span, \multispan, booktabs/longtable |
table width/rules match reference |
| M4 | math lists, scripts, fractions, radicals, accents, delimiters | arXiv formulas render without overlap |
| M5 | NFSS/TFM metrics, CM/Latin Modern | same line/page breaks as reference |
| M6 | class/package execution (article, sn-jnl) |
Overleaf page-count parity |
| M7 | \special, PDF XObjects, hyperref annotations |
PDF structure parity |
Current limits
- The M0 paragraph model is a character-count placeholder; it does not run the TeX paragraph algorithm yet.
- Page breaking only handles vertical boxes/glue; penalties are recorded but not interpreted.
- No macro state, output routine, math, fonts or PDF output in the new core yet.
- The v1 server and project API still use
src/rust_typesetand are unchanged.
Verification
cargo test -p texrra-tex-core --offline
The four M0 tests cover page splitting, checkpoint serialization and page-local editing.