# Changelog ## Unreleased ### Fixed - A warm-up compile that kills the live engine (a command in the warm-up text hits LuaTeX's 100-error limit, as luatexja does with a CJK font it cannot load) restarted the engine after every pass, forever. After one such crash rtex stops warming the engine until the preamble changes (#54). - Count registers named like counters but made with `\newcount\c@name` (ltmermaid's diagram number) are replayed and restored by the live engine like LaTeX counters: each live compile advanced them, so ltmermaid rendered every diagram again on each keystroke under a new name (#57, by Steve-Li-1998). - A paragraph ending in a block environment with a heading right on the next line (`\end{equation}` then `\section{B}`, no blank line) goes live again: the paragraph and the heading were mapped to the same span, so edits to it went to a full compile (#53, by dfshfghj). - Files loaded with the subfiles or import package (`\subfile`, `\subimport`) are read from the session's copy of the project: TeX read the saved file from the real project folder instead, so the editor's unsaved text of a subfile never reached the full compile, and its paragraphs had no source position, so the preview could not follow the cursor there (plugin #40). ### Documentation - `EngineState` and `LayoutUpdate` are not ordered: the first layout can arrive before the engine's first `Ready` (#55). ## 0.0.8 (2026-11-22) ### Fixed - `DisplayList::to_binary` (what the C API hands to hosts) dropped the item after every transformation: the `set` after a `save`, so a scaled or rotated box was drawn untransformed, and the item after a `restore`. `rtex serve` sends JSON and was not affected. - biblatex with `backend=bibtex` gets its bibliography from a pass: BibTeX did not find `-blx.bib`, which biblatex writes next to the aux file, so it failed on every run. - The bibliography program runs again within a run when a pass gives it more to do (an entry whose note cites another entry); it ran once, and the second entry stayed unresolved. - A main file in a subfolder reads `\input{name}` (and other files found by name) from its own folder even when a same-named file sits at the top of the project, as `latexmk -cd` does (#40). - The live preview no longer draws another graphic of the document in place of an `\includegraphics` image that comes after cached pictures: `images_info` is keyed by the image rule index the IMAGE items carry, not the PDF object number (#41, by SunXin121). - Two-column documents: a paragraph that runs from one column into the next on the same page gets live updates again. Its rows were placed as one run from its first line, so it either waited for a full pass ("the placement would fall off its page") or was drawn with the next column's rows under the previous column. Placements now have one fragment per page column (#47). - `rtex` no longer leaves a LuaLaTeX server behind when it exits (quit, end of input, a signal) while a document's preamble is still loading: the server's open of its reply channel blocked forever once `rtex` was gone. A server whose start fails or times out is now stopped too. - Floats compiled live run their own `\begin{figure}…\end{figure}`, so they get what the class's float environment and packages set up around `\@float` and `\@xfloat`: Elsevier's cas-sc captions (sans, 9 pt, `\@makecaption` set by the environment), setspace's single spacing in floats under `\doublespacing`, float.sty's styles. The live engine used to start the float box with the kernel's steps only, and such a caption came back in the body font and spacing with status `ok` (#49). ### Faster - Background passes: the capture writes each page's display list in the binary format, as the page ships, instead of building a table per page and encoding all of them as JSON at the end of the run. On the 300-page TFM book the page lists take 0.25 s of a pass instead of 0.98 s (12.5 MB instead of 36 MB), and a later layout after a one-character edit takes 1.6 s instead of 2.4 s (Apple M5 Pro, median of three sessions of five layouts each). The pass directory holds `.rtex-page.bin` in place of `.rtex-page.json`; `rtex dl2json` prints one as JSON. Page lists now carry what the binary format documents: a flag's `_detail` is `1` instead of a string, and fonts have no `embedding` or `encodingbytes`, a font's `type` is `real` or `virtual`, an unsupported item's numeric detail is a string, and a page has no `inserts` count. A line's glue set `gs` is LuaTeX's exact value (the JSON round trip could change its last digit), and a page lists the images known when it shipped, not every image of the document. `PageUpdate.hash` is the hash of the page's bytes. - A bibliography request that cannot be met no longer costs every layout five passes. While a citation's key is missing from the database (a `\cite` being typed, with biblatex's BibTeX backend), or while Biber or BibTeX fails, biblatex writes "Please (re)run Biber … and rerun LaTeX afterwards" on every pass. rtex took that as a reason to run again, up to the pass limit, and reported `PassLimitReached` with "aux family still changing" although nothing changed. Once the bibliography program has run on what the pass gave it, that request no longer starts a pass. A layout after an edit is then one pass: 1.9–2.1 s instead of 8.9–11.1 s on the 100-page mixed book with a Biber that fails. ## 0.0.7 (2026-11-06) ### Added - Optional `math_owner_attribute` in Rust, C/JSON and `rtex serve` configuration: hosts can attach opaque ids to math source with one LuaTeX attribute and receive glyph ownership and math-field boxes in `math_owners` display-list metadata (binary record `0x29`). Truly empty fields get zero-size anchors without changing nonempty fields or PDF output. Off by default. - `rtex serve --compile-timeout-ms` and `--pass-timeout-ms` set the live-compile and background/export pass timeouts that the Rust and C/JSON configurations already take (`compile_timeout`, `pass_timeout`). A host that drives `rtex serve` could not shorten the five-minute pass timeout before. Defaults are unchanged. ### Fixed - `rtex serve` settles on documents whose `\maketitle` makes a title page of its own (the report and book classes, `article[titlepage]`). The engine warm-up compiled the `\maketitle` unit, which redefines `\maketitle`; that leak restarted the engine and ran a pass, and the pass's layout warmed the same unit again, so the engine restarted about every 0.4 s forever. The warm-up now skips units whose compile leaked. - The build directory no longer copies the main file's folder. Each snapshot a pass reads (`src`, `src-body-0`, `src-body-1`) holds only the edited sources, in real folders, and links everything else: a folder without sources is one link to the project's folder, a file next to a source a link to the project's file. On Windows without Developer Mode, folders become junctions and files hard links, or copies up to 8 MiB (a bigger file is still found through `\input@path` and the graphics path). Three copies of a big folder filled users' disks, and every pass walked all of it (plugin issues #13, #15). A snapshot from an earlier version is replaced on the first pass. - Empty unicode-math radical degrees now report a zero-size `degree` ownership point, derived from the converted radical and its MATH parameters without changing PDF output. - `set_document` applies only the bytes that differ from the text the session holds. It replaced the whole file, which counted as a preamble edit: the live engine restarted, every unit got a new id, and the first layout no longer had contexts for them. A host that sent its buffer 0.3 s after opening got its first live update after the second layout (24.2 s on the 300-page book, 3.1 s on the 10-page one); now after the first (8.1 s, 1.4 s). The text the session already holds changes nothing (`routed` is `"background"`, reason `unchanged`). ### Faster - Background passes on long documents: the capture writes its per-page display lists 2.7× faster (one `string.format` per glyph, no per-element calls for number arrays, no `gsub` for strings with nothing to escape; the JSON is byte-identical), and installing a layout parses only the pages whose capture text changed instead of parsing every page and serializing it again to hash it. The paragraph flags and definition scan are cheaper too. On the 300-page TFM book a later layout after a one-character edit takes 4.8 s instead of 7.6 s and the first layout 10.1 s instead of 16.4 s; on the 100-page book 1.6 s instead of 2.6 s and 3.6 s instead of 5.7 s. `PageUpdate.hash` is now the hash of the page's capture text; it still changes whenever the page does. - Live updates on Linux: the engine thread reads the live engine's response FIFO itself instead of taking each frame from a reader thread, which saves one thread wake-up per result: about 0.04–0.07 ms of the fixed cost of an update (`rtex probe`, one-line paragraph). The FIFO is given room for 1 MB, so the server still finishes writing a large result while the host is not reading. macOS and Windows keep the reader thread. - A keystroke updates a file's span and line tables in place instead of rebuilding them: on the 300-page book (one 880 KB file), applying an edit takes about 0.02 ms less (0.075 → 0.055 ms in a running session). What is left is mostly moving the text after the edit. - The live engine resets the document's counters after each compile by register number instead of looking each `\c@` up by name: 0.004–0.006 ms instead of 0.009–0.017 ms for the 18 counters of the book fixtures. - The live engine splits a unit's source into lines and finds its control sequences with plain string searches instead of Lua patterns: about 0.019 ms less per compile of a 1.5 KB paragraph, 0.002 ms for a one-line one. ## 0.0.6 (2026-11-01) ### Changed - lopdf 0.42 (from 0.36): 0.36 overflows the stack on deeply nested PDF objects (RUSTSEC-2026-0187), and rtex reads every pass's PDF with it (#24). ### Fixed - A background or export pass that never ends (`\directlua{while true do end}`) is killed after `pass_timeout` (default 5 minutes, `pass_timeout_ms` in the C/JSON config) and the layout reports `Failed` with "lualatex was stopped after … s". It kept one CPU busy forever, and no layout or export finished after it, even once the source was fixed. A pass whose lualatex was killed by a signal (a CPU limit, the OOM killer) reports `Failed` too; it reported `Ok` with whatever pages it had written (#22). - `rtex serve` no longer exits (status 101, "start of range should be a character boundary") on an `edit` whose offset falls inside a multi-byte UTF-8 character. A range inside a character, a start after the end, an offset past the end of the file and a negative or non-integer offset now get `reply: error` and leave the session running; they were clamped before, which could turn a body edit into a preamble edit (#25). - `set_document` refuses a new file outside the project (`../escape.tex`, an absolute path elsewhere) with `reply: error`. The snapshot wrote such a file at that path (#26). - A preamble that ends the run before `\begin{document}` (a `\stop`, a half-typed preamble) no longer restarts the live engine every second until the preamble changes. A failed start is retried only after a preamble edit or a new pass, the failure says "the preamble ended the run before `\begin{document}`" instead of quoting PDF statistics, and the full compile of that text reports `Failed`: it read the previous pass's capture file and reported `Ok` with the old pages (realtime-tex-vsc-plugin#10). - Documents that load the `float` package no longer report "Unknown float option `\'", "`U'", "`s'" for every float. The capture hooked the end of `\@xfloat`, which `float` redefines with a parameter text ending in `[`, so the hook was read as the float's placement. The float box is now recorded at `\end{figure}` and `\end{table}` instead (realtime-tex-vsc-plugin#8). - A main file in a subfolder (`cv/sop/sop.tex`) reads document-relative paths from its own folder, as `latexmk -cd` compiles it. `\input{body}`, a figure next to the main file and `\graphicspath` entries are found in that folder, and bibtex and biber run there, so `\bibliography{../../references}` is found and citations resolve. A `.bst` file at the top of the project is found too (`BSTINPUTS`, like `BIBINPUTS`). - Live edits no longer stop for good after a paragraph that typesets no rows (only a `\label`, `\vspace` or `\noindent`) is typed next to another paragraph typed fresh, before the background pass. Its placement read the first of no rows and the engine thread panicked ("index out of bounds" in `layout.rs`), so no edit was live again until the engine restarted (#13). - The paragraph after a run-in heading's own paragraph (the second paragraph under an IEEEtran `\subsubsection` or a `\paragraph`) is live, and so is a heading right after a run-in heading's paragraph. They start under the heading's `\everypar`, which the live engine cannot replay; by then it only restores `\clubpenalty` and empties itself, so the capture records it as the default `\everypar` (#14). - A live-engine error is withdrawn once a pass compiles the fixed source, and a pass without errors clears the previous pass's errors, so a host no longer shows an error after the text is valid again. A paragraph that crashed the live engine (often a half-typed command) goes live again when it is edited after a clean pass, instead of waiting for the preamble to change; after three crashes in a row it still waits (#11). - Run-in headings (`\paragraph`, `\subparagraph`, IEEEtran's `\subsubsection`) are live. The source cut such a heading off from the paragraph or list that sets its title, so the heading alone typeset nothing, and an edit in that paragraph was drawn without the title in the wrong place until the pass. The heading's span now runs on through that paragraph or list, a label and a blank line between them included, and the capture keeps a list that takes the title in the heading's unit. The IEEEtran corpus paper goes from 20 to 27 of 27 units live, all exact (#15). ## 0.0.5 (2026-10-19) ### Fixed - A main file whose name has a space (`my paper.tex`) works. LuaTeX quotes such a job name, and the capture wrote its results under the quoted name, so no layout ever arrived (#8). - A page without glyphs (a blank page left by `\cleardoublepage` with `\pagestyle{empty}`) no longer makes the whole layout fail with "invalid type: sequence, expected a map". - A figure or table with a comment line or `\vspace` right above it, or a comment after its `\end`, compiles in the live engine. The engine looked for `\begin{figure}` only at the very start of the unit and for `\end{figure}` only at its very end, so it typeset the `\begin` as text and failed with "Not in outer par mode". - A figure, table, list or other block environment that is the last thing in an `\input` file is live. Unless the file ended with a blank line, its edits went to the background pass: the trailing space rtex keeps for a paragraph at the end of an `\input` file was added after the environment too, and it no longer ended with its `\end`. - A file `\input` in the preamble (a macro file, say) is loaded once by the live engine. It was also read again as document setup, so every engine start logged "Command ... already defined" for each of its macros. - `\mathbf` after `\bm` (fontspec documents) is right in the live engine. Its memoized math font setup kept the bold math version's alphabets when math returned to the normal version, so `\mathbf{M}` came out in the wrong font. After a footnote, TeX could even loop on it until the engine stopped, and the paragraph was not live again until the preamble changed. - The first page of an IEEEtran document is drawn from its display list, not from the PDF. Under LuaLaTeX the class writes a `\special{papersize=…}`, which LuaTeX's PDF backend ignores, and rtex took it for something a display list cannot show. Only `pdf:` specials, the ones the backend draws, mark a page as degraded now. - A table edited live in IEEEtran keeps the class's `\footnotesize`. The live engine set every float box like the LaTeX kernel, in `\normalsize`; it now uses the float box the class sets up for tables and figures. - IEEEtran's `\subsubsection`, a run-in heading like `\paragraph`, waits for the next pass instead of going live without the paragraph its title shares a line with. rtex knew run-in headings only by name; the capture now records which headings the class sets run-in. - Math set with newtxmath, or any font whose TFM comes with a `.vf`, is right in the live display list. LuaTeX reports such a font as a real font and reads its `.vf` only when it writes the PDF, so rtex did not expand it: glyphs named `ntxmi`, `ntxsy`, … with their virtual character codes, which have no outline file in `pdftex.map`, and a host drew the wrong characters (`+` came out as `Ï`). rtex now reads the `.vf` itself and names the real fonts (`NewTXMI`, `txsys`, …). ### New - IEEEtran's `IEEEkeywords` and `IEEEdescription` (a nomenclature, with `\IEEEsetlabelwidth` and `\IEEEusemathlabelsep`) update as you type, like the standard lists. Commands a document class provides can be allowed like a package's; these two are allowed with IEEEtran only. ### CI and repository - The corpus has an IEEEtran journal paper (two columns, a nomenclature, run-in headings, floats). CI checks that at least 18 of its units are live and that all of them are exact. - CI installs newtx (with txfonts and kastrup) for a test that a live edit in newtxmath math names the real fonts, not the virtual ones. ## 0.0.4 (2026-10-12) ### Fixed - **Two-column documents** (IEEEtran, `twocolumn`) are live again. When a column break fell inside a paragraph, the page's two-column box was recorded as a row of that paragraph, and the lines inside it lost their placements: in a 12-page IEEEtran paper almost no body text was live (#2). The capture now leaves everything the output routine builds out of units. - Comment lines inside or right above a paragraph no longer send its edits to the background pass. rtex read two `%` lines in a row as a blank line (a paragraph break); like TeX, it now drops the end of a commented line too (#3). - A paragraph with a `\marginpar` is live in probe mode, with the note in the margin following after the next pass, like footnote text. The live engine reports the note as an insert. - Diagnostics keep the whole text of LaTeX, class and package messages, including the `(LaTeX)`/`()` continuation lines. Before, only the first line came through, so an error such as "Mismatched LaTeX support files detected" lost the lines that say which versions do not match (#1). ### CI and repository - `scripts/install-texlive.sh` installs only missing packages and contacts the TeX Live repository only then, updating tlmgr first. A newer tlmgr on CTAN stopped re-runs over an existing installation with "tlmgr itself needs to be updated". ## 0.0.3 (2026-10-11) ### Fixed - **Live typing on Windows with MiKTeX.** The live engine exited at startup with "exit code: 1" on every MiKTeX installation (realtime-tex-vsc-plugin#1): MiKTeX refuses to let LuaTeX write outside the output directory, which includes the engine's response pipe. rtex now sets `MIKTEX_ALLOWUNSAFEOUTPUTFILES=1` for the LuaLaTeX processes it starts, the MiKTeX equivalent of the `openout_any=a` it already sets for TeX Live. - When the live engine cannot start, the error quotes the first TeX or Lua error from its log instead of only the exit code. ### New - **Prebuilt binaries** for Linux (x86_64, arm64), macOS (Apple silicon, Intel) and Windows (x86_64), attached to each release by CI. Each holds `rtex`, the shared C library, `rtex.h` and the support files. - `rtex` finds its support files next to its executable (`share/rtex/tex`), so an unpacked archive works from anywhere. `rtex doctor` checks the installation. ### CI and repository - A job runs a live-editing session on Windows with MiKTeX, in paths with spaces and non-ASCII characters and on a CRLF document. - GitHub counts the project as Rust: fixtures, benchmarks and the TeX/Lua files are marked as vendored for language statistics. ## 0.0.2 (2026-10-10) ### New - **Windows support.** rtex runs on Linux, macOS and Windows. CI tests all three against a real TeX Live. - **Much more goes live.** Not just plain paragraphs any more, but: - paragraphs with display math, footnote marks, references and citations (natbib and biblatex); - lists, quotes, theorems and proofs, figures and tables with images and captions, verbatim and listings; - headings, the title block, manual bibliographies; - your own macros and environments, and text in `\input`/`\include`d files. Counters, `\the` formats and macros the body redefines are restored per unit, so numbers come out right. - **Probe mode** (the default). A paragraph that uses commands rtex does not know is no longer sent to the background automatically. rtex compiles it once as the last pass saw it and compares the result with the page. If it matches exactly, edits go live. Definitions that leak out of a paragraph are detected. - **New paragraphs and splits stay live.** A paragraph you split or type fresh borrows its neighbour's settings until the next pass. - **Faster background passes.** - A standby LuaLaTeX with the preamble already loaded typesets only the body (3–4× faster for short documents). - Unchanged TikZ/pgfplots pictures are reused from the previous pass (on a 111-page document with 120 pictures, 45 s → 18 s per pass). - Slow multi-pass runs show each finished pass right away. - **Bibliographies and indexes run automatically.** biber, bibtex, makeindex, and imakeidx's own program and options. - **Configurable time budget** per live compile (`fast_budget_ms`, default 50 ms). - **Diagnostics for engine failures.** Set `debug_dir` and every failure leaves a bundle: what was sent, the TeX log, and a stage-by-stage trace. - **New `rtex` subcommands.** `rtex probe` shows where a document's live latency goes, and `rtex verify --permissive` / `--pic-cache` check probe mode and the picture cache. ### Faster - **About 0.5 ms per keystroke for a one-line paragraph, 1.1 ms for four lines**, independent of document length. That is down from 0.8 and 1.5 ms in 0.0.1. The engine is driven by raw frames, the editor's thread writes straight to an idle engine, and LaTeX work that cannot be seen in a paragraph (running-head marks, repeated math font setup, file probes) is skipped in the live engine. ### Fixed Most of these were found by running real documents (a 111-page TikZ-heavy set of notes and a 58-page document with luatexja, biblatex, imakeidx, glossaries and tcolorbox): - The response channel is read by a dedicated thread. On macOS a large result could block the engine until the watchdog killed it. - A Lua error inside the live engine is reported at once instead of hanging until the watchdog. - Projects with subfolders, and figures that are PDFs, now work in background passes. - Layouts stopped converging when bookmarks recorded the pass directory, or the index was missing. Both are fixed. - `\begin{document}` inside comments or verbatim no longer confuses rtex. - biblatex citations are live in a session opened without an earlier build. - glossaries' first-use forms are right in live updates. - Running heads no longer count as part of the paragraph at the top of a page, and appendix numbering is right. - Paragraphs that start inside a group (`{\em …}`) now have their lines. - Fixed a deadlock when an edit arrived while a layout was being installed. - A paragraph that crashes the engine is kept off the live path instead of crashing it on every keystroke. - PDFs of earlier layouts stay valid while the host reads them. Two engines could write the same file, which produced blank pages. ### Changed - The library, C ABI, display-list format and engine protocol are versioned together as 0.0.x. Nothing is frozen before 0.1. - The C ABI takes more configuration keys: `fast_budget_ms`, `eligibility`, `picture_cache`, `debug_dir`, `unit_envs` and `warm_background`. ## 0.0.1 First version: - a persistent LuaTeX engine that re-typesets single paragraphs; - the capture package; - the display-list format (binary and JSON); - the Rust library with a C ABI; - background passes with honest convergence reporting; - PDF export; - the fidelity checks; - fixtures and benchmarks.