Repository navigation
Conversation
… geometry Two of the corpus lane's ranked divergences (#258), both entirely inside this crate, both fixed by reading what the class file says instead of a constant. **`\subsubsection` was never numbered** (#258 rank 6, `min3-subsubsection`, heading text 35.00 bp too far left). `adapt_cached` had two readings of one counter: the body heading used `options.default_secnumdepth`, a flat `2` for every class, while the contents list already resolved article.cls line 255 `\setcounter{secnumdepth}{3}` vs report/book.cls `{2}`. So an `article` numbered its `\subsubsection` in the ToC and not in the body. The heading now reads `ResolvedDocument::secnumdepth` (class-geometry's transcription of the class's own `\setcounter`) and `toc_secnumdepth` is that same value -- one counter, one reading. An explicit `\setcounter{secnumdepth}{n}` still wins, and a document with no `\documentclass` still keeps the caller's default. **`description` was invisible to the list geometry** (#258 rank 9, `min-description`, dx -24.91 bp and the list 11.96 bp short). `list_stack_at`, `gap_has_list_end` and `list_env_after_begin` matched only `itemize`/`enumerate`/`thebibliography`, so a `description` item fell through to the `enumerate` defaults. article.cls lines 360-365 are now transcribed: \list{}{\labelwidth\z@ \itemindent-\leftmargin \let\makelabel\descriptionlabel} \newcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\bfseries #1} `ListGeom` gains `label_style: ItemLabel` (`Llap` = latex.ltx's `\makelabel##1{\hss\llap{##1}}`, `Description` = the above). For `Description`, `\@item`'s `\hskip\itemindent \hskip-\labelwidth \hskip-\labelsep` with `\labelwidth\z@` and `\itemindent-\leftmargin`, plus the label box's own leading `\hspace\labelsep`, cancel to a single `-\leftmargin`: the term is set flush on the left margin in the bold body face and the item text follows one `\labelsep` after it, while the wrapped lines still hang at `\@totalleftmargin`. `\topsep`/`\itemsep`/`\parsep` come from the existing `\@list<i>` path, which was already environment-agnostic. **A multi-word `\item[...]` label was one shaped run**, so its interword spaces took the *font's* `space` advance rather than TeX's `\fontdimen2` -- 1.91 bp per space too wide in Latin Modern Bold at 10 pt, which is what was left of `min-description` after the geometry was right. `label_items` now sets each word as its own box with `\fontdimen2` between them, which is what an `\hbox` packed at natural width does. Single-word labels (every bullet, every `\labelenum<i>`, every `thebibliography` tag) are unchanged. Measured against the corpus lane's reproducers (#258 @ c051d56, TeX Live 2025 references, geometry only -- this host has no rasterizer), candidate vs reference word origins in bp: | probe | before | after | |---|---|---| | `min3-subsubsection` | max \|dx\| 35.00, 20/24 words within 0.5 bp | max \|dx\| **0.75**, 22/24 (the residual is the `\verb` run on substituted `ectt` metrics) | | `min2-headings` | max \|dx\| 35.00, 37/40 within 0.5 bp | max \|dx\| **0.01**, **41/41** | | `min-description` | max \|dx\| 24.91 / \|dy\| 11.96, 6/38 within 0.5 bp | **0.01 / 0.00**, **38/38** | | `min-toc`, `min-chapter` | exact | unchanged | | `min2-itemize`, `min2-nested-lists`, `min3-itemize-only`, `min3-enumerate-only`, `min3-itemize-multipar`, `min4-itemize-wrap` | — | unchanged to 0.01 bp | New tests: `tests/sectioning_depth.rs` (article numbers `\subsubsection`, report does not, an explicit `\setcounter` still wins) and `tests/description_list.rs` (term at 72.000, second term word at 99.894, item text at 128.843, wrapped line at 96.907 -- the pdflatex coordinates of `min-description` -- and the term in the bold face, the body not). Implementation-Agent: Claude Opus 5 (engine layout lane, linux-primary / NixOS) Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution under the observed-Cursor-limit user override) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
#258 rank 8 (`min3-baselinestretch`, max |dy| 11.96 bp): the macro was not read at all, so a document that asks for one-and-a-half or double spacing was set at single spacing throughout. `\baselinestretch` is not a length the body applies once. latex.ltx defines `\def\baselinestretch{1}` and `\@setfontsize` ends with \baselineskip\baselinestretch\baselineskip so *every* `\@setfontsize` -- `\normalsize`, `\small`, `\footnotesize`, the `\Large` of a `\section`, the `\LARGE` of `\@maketitle`, the `\huge` of `\chapter` -- multiplies the leading of the size it selects. It does not touch `\lineskip`/`\lineskiplimit` (the `.clo`s' `\normallineskip`) or the fixed `\setlength`s such as `\footnotesep` and `\skip\footins`. So this is implemented where sizes are selected, not at one site: - `Stylesheet` gains `baselinestretch` and `set_baselinestretch`, which scales the leadings it already holds (the body's and all three headings'); - `FootnoteParams::of`, the three `class_geometry::FontSize::metrics` closures (`\chapter`, `\part` in flow and on its own page, `\maketitle`) and `table_box`'s non-body-size `\strutbox` scale their own table's value through `Stylesheet::stretched`; - everything else already reads `Stylesheet::baselineskip_pt` and follows. `adapter::baselinestretch` reads the factor from the source the way `\setlength{\parskip}` is already read: `\renewcommand{\baselinestretch}{f}` with a braced or unbraced first argument, the `*`-form, `\def`, `\newcommand`/`\providecommand`, and `\linespread{f}`, which latex.ltx defines as exactly `\renewcommand{\baselinestretch}{f}\@currsize`. The last setting in source order wins, as for `\setlength`. A non-numeric or non-positive argument is ignored rather than guessed at. Measured against the corpus lane's reproducers (#258 @ c051d56, TeX Live 2025 references, geometry only), candidate vs reference word origins in bp: | probe | before | after | |---|---|---| | `min3-baselinestretch` | max \|dy\| 11.96, 19/42 words within 0.5 bp | **0.01 / 0.00**, **42/42** | | `min-footnote`, `min-maketitle`, `min-chapter` | exact | unchanged | The 10 pre-existing real-world fixtures produce a **byte-identical** rendering-v2 display list against a control build of this branch's base (`hw1`, `hw2`, `cv`, `letter`, `lecture-notes`, `math-sheet`, `inline-math`, `input-bibliography`, `article-twocolumn`, `unicode-accents`): none of them sets the macro, and with the factor at 1 every multiplication is the identity. New `tests/baselinestretch.rs`: 1.5 gives the probe's measured 17.932 bp body pitch with the first baseline still where `\topskip` puts it; `\linespread`, the unbraced form and the last-wins rule agree exactly; a `\section` heading's and a footnote's own leadings scale by the same 1.5; and `\renewcommand{\arraystretch}` is not mistaken for it. Implementation-Agent: Claude Opus 5 (engine layout lane, linux-primary / NixOS) Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution under the observed-Cursor-limit user override) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
#258 rank 4 (`fixtures/divergence-probes/min-paragraph`): the heading was not bold, sat `\parindent` in (+14.94 bp) and was missing 13.94 bp of space above it, per occurrence. `Stylesheet` knew only three heading levels -- `section_spec(level).expect( "levels 1..=3")`, `headings: [HeadingStyle; 3]`, `heading()` clamping to 3 -- and threw the one thing that distinguishes levels 4 and 5 away: `SectionAfter::RunInEm` was mapped to `Skip::ZERO`, so even if a level-4 heading had arrived it would have been set as a display `\subsubsection`. The table is now the class's five (article.cls lines 302-321) and `HeadingStyle` carries `\@startsection`'s `#3` (`indent_pt`, `\subparagraph`'s `\parindent`) and its `#5` when non-positive (`run_in_em`). A run-in heading is not a vertical block at all. `\@sect` stores it in `\@svsechd` instead of setting it, and `\@xsect` installs an `\everypar` that fires on the *next* paragraph: it drops that paragraph's `\parindent` box (`{\setbox\z@\lastbox}`), unboxes the heading and adds `\hskip -#5`. `adapter::RunInHeading` holds the heading for exactly that long -- - the items are built with the compiler's own weights (`items_for_weighted`), because unlike `heading_block` the paragraph they land in is not bold at its base, so `\bfseries` has to reach them; - `#3` goes in front as an `Item::HSpace` and `\hskip -#5` after as `Item::Quad`, which is evaluated in the paragraph's own font, as `\everypar` is; - `\addvspace{#4}` (`3.25ex`) rides along as the paragraph's `addvspace_before`, so it still collapses against a preceding skip the way `\addvspace` does; - the paragraph is not indented and is not joined onto the previous one; - a heading with nothing to run into (a heading, rule, picture or the end of the document follows) is flushed as an unindented paragraph of its own. **Depends on the compiler-side PR and a vendor re-pin.** `vendor/compiler` does not emit `Block::Heading` above level 3 yet, so this arm is inert against the current pin -- the code builds and every existing test is unchanged either way. `tests/run_in_headings.rs` is therefore behind the `run-in-headings` feature (off by default, documented in `Cargo.toml` exactly as `amsmath-inline` and `request-date` were before their re-pins); turn it on in `default` when vendor/compiler carries the levels. Measured with `vendor/compiler` mirrored locally from the compiler PR (that mirror is **not** part of this commit), against the reproducer's TeX Live 2025 reference, geometry only -- this host has no rasterizer: | probe | before | after | |---|---|---| | `min-paragraph` | max \|dx\| 14.94 / \|dy\| 27.87 bp, 27/74 words within 0.5 bp | **0.01 / 0.01**, **74/74** | | a local `\paragraph` + `\subparagraph` + trailing-`\paragraph` probe (90 words) | — | max \|dx\| 0.01 / \|dy\| 0.01, **90/90** | `cargo test --release --features run-in-headings`: 4 new tests pass (the heading opens the next paragraph's first line at x 72.000 / baseline 141.629 with the body resuming at 171.438; it is bold and `\normalsize`; `\subparagraph` starts at 86.944 = one `\parindent` in; a trailing `\paragraph` is still set). Without the feature the whole suite is unchanged, 0 failed. Against a control build of this branch's base, with the re-pin *absent*, the rendering-v2 display list of all 22 `fixtures/real-world` documents is byte-identical, and amsmath is 59/59 within 0.5 bp with HW1/HW2 at 3 pages, 0 errors, 0 overfull. Implementation-Agent: Claude Opus 5 (engine layout lane, linux-primary / NixOS) Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git execution under the observed-Cursor-limit user override) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
…ion` #258 rank 1, the highest-frequency layout divergence in the corpus: the `abstract` body was set at `\normalsize` and the full measure with no head at all, so everything below it sat 24.58 bp too high. The blocker the previous lane named (#292) was a missing capability, not a constant: `paragraph_block` hard-coded `body_size_pt`/`baselineskip_pt`, so nothing could be set at a size other than `\normalsize` *with that size's own leading*. `adapter::SizedPara` now carries what `\@setfontsize` changes for one paragraph — the size, that size's `\baselineskip`, a `\parindent` in the new size's own `em`, a trailing `\vspace` in `em` of the font its last word is set in, and the closing `\@endparenv` skip of a list opened while the size was in force. article.cls 377-387 / report.cls 452-462, transcribed against the vendored `document-style` (wiring `crates/title-layout` in was the alternative: it depends on the *sibling* `document-style`, so its `Skip`/`Pt`/`Stylesheet` are different types from the vendor mirror this crate builds against, and adding it would break the `git archive` property the Cargo.toml documents. It also models `gap_before_heading` as `\topsep + \parskip` with no `\partopsep`, and its article.cls quote predates the `\vspace{-.5em}`): * the head is `\begin{center}{\bfseries \abstractname\vspace{-.5em} \vspace{\z@}}\end{center}` at `\small`, centred at the FULL measure (`center` is a `\trivlist`, `\leftmargin` 0); * the body is `\quotation`: `\leftmargini` both sides, `\listparindent 1.5em` resolved in `\small`'s own `\fontdimen6` (13.87161 pt, not the `\normalsize` quad), `\small`'s 11 pt leading throughout; * the opening glue is `\normalsize`'s `\topsep + \partopsep + \parskip` (10 pt plus 4 minus 5): `\small` only `\def`s `\@listi`, it never executes it; * the closing glue is 6 pt plus 3 minus 3 — `\small`'s own `\@listi` `\topsep` of 4 pt plus `\partopsep`, not `\normalsize`'s 8 pt; * the `quotation`'s own opening `\addvspace\@topsep` is absorbed whole by the `\end{center}` skip already on the list at every class size. Every number above is read off pdfTeX's own vertical list for `fixtures/divergence-probes/min-abstract` (`\showoutput`, TeX Live 2025), quoted in `abstractenv.rs`. The compiler has no model for the environment (it reports it and sets the body as plain text), so the pipeline reads it from the source bytes, the way it already reads `tikzpicture`, a list's `\begin` keys and a paragraph's `\newpage`; its now-superseded diagnostic is dropped the way `toc::superseded_commands` drops the contents-list ones. No compiler change and no vendor re-pin, so the fix is live rather than feature-gated. Not set here, reported as limitations instead of approximated: the `\if@twocolumn` branch (`\section*{\abstractname}`) and the `titlepage` branch (a page of its own between `\null\vfil`s). `book.cls` defines no `abstract`, so it keeps the compiler's warning. Measured, `tools/visual-oracle/rank.py` against the pinned TeX Live 2025 reference, geometry only (no rasterizer on this host): min-abstract p1 median dy -24.584 -> -0.000, max |dy| 35.54 -> 0.00, words aligned 92/93 -> 93/93, reflowed 1 -> 0. The residual max |dx| 1.30 is the probe's `\verb` on substituted `ec` metrics (the bundle has no `ectt*.tfm`), the same caveat #292 recorded. Corpus gates are still running; this is committed early so the work is not held locally. Implementation-Agent: linux-abstract lane (Claude Opus 5) Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 14, 2026
Merged
compiler: preamble \setlength, \addtolength and TeX length assignments, with TeX's unit factors
#432
Closed
Merged
Merged
Contributor
Author
|
Closed under the old-engine freeze (DESIGN.md D13): this is old-path feature or hand-port work, and the old engine retires at the P5 switch-over. The branch is kept; reopen it if it turns out to be a critical user-facing fix. — kabir-claude (Commander), nightly review 2026-09-30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three of the corpus lane's ranked layout divergences (#258), all fixed by
reading what the class file says instead of a constant, plus the pipeline
half of a fourth that needs the compiler PR and a vendor re-pin.
Split as the lane convention requires: this is the pipeline PR; the
compiler PR is #291.
What changed
\subsubsectionwas never numbered (#258 rank 6, heading text 35.00 bptoo far left).
adapt_cachedhad two readings of one counter: the bodyheading used
options.default_secnumdepth, a flat2for every class, whilethe contents list already resolved article.cls line 255
\setcounter{secnumdepth}{3}against report/book.cls{2}. So anarticlenumbered its
\subsubsectionin the ToC and not in the body. Both now readResolvedDocument::secnumdepth; an explicit\setcounterstill wins.descriptionwas invisible to the list geometry (#258 rank 9, dx −24.91bp, the list 11.96 bp short).
list_stack_at,gap_has_list_endandlist_env_after_beginmatched onlyitemize/enumerate/thebibliography,so a
descriptionitem fell through to theenumeratedefaults. article.clslines 360-365 are now transcribed —
\labelwidth\z@,\itemindent-\leftmarginand\descriptionlabel's\hspace\labelsep\normalfont\bfseries— as a newListGeom::label_style.While there: a multi-word
\item[...]label was shaped as one run, so itsinterword spaces took the font's
spaceadvance instead of TeX's\fontdimen2(1.91 bp per space too wide in Latin Modern Bold at 10 pt);label_itemsnow sets each word as its own box, which is what an\hboxpacked at natural width does.
\baselinestretchwas not read at all (#258 rank 8, max |dy| 11.96 bp),so a document asking for one-and-a-half or double spacing was set single.
It is not a length applied once:
\@setfontsizeends with\baselineskip\baselinestretch\baselineskip, so every size selectionmultiplies that size's own leading. Implemented where sizes are selected —
Stylesheet::set_baselinestretchfor the body and the headings, andStylesheet::stretchedat the three sites with size tables of their own(footnotes,
\chapter/\part/\maketitle,p{}cells).\linespread{f}, the unbraced\renewcommandform and\defare the samecommand; a non-numeric argument is ignored.
Run-in headings (#258 rank 4, not bold, +14.94 bp indented, 13.94 bp of
space missing).
Stylesheetknew three levels and mappedSectionAfter::RunInEmtoSkip::ZERO; it now carries the class's five with\@startsection's#3and its non-positive#5.adapter::RunInHeadingholds such a heading until the paragraph its
\everyparfires on, drops thatparagraph's
\parindentbox, sets the heading in the compiler's own boldweight and follows it with
\hskip -#5evaluated in the paragraph's font.Measured, against the reproducers
tools/visual-oracle/rank.pyoverfixtures/divergence-probes, candidate vsthe pinned TeX Live 2025 reference, word-origin deltas in bp. Geometry
only:
linux-primaryhas nopdftoppmand no Ghostscript, so no pixelcomparison was run.
min-descriptionmin3-baselinestretchmin-paragraph†min2-headingsmin3-subsubsection† with
vendor/compilermirrored locally from the compiler PR; that mirror isnot part of this branch. ‡ the residual is the probe's
\verbrun onsubstituted
ecmetrics — the bundle has noectt*.tfm, so those positionsare not a line-breaking measurement. Verified: the same document with the
\verbreplaced by ordinary words is exact, 27/27 words within 0.01 bp.No probe of the 43 got worse. The regression floor is intact:
min-toc,min-chapter,min-maketitle,min-footnote,min-quote,min-twocolumn(439/439),
min-tabular,min-curly-quoteand the six itemize/enumerateprobes are unchanged to 0.01 bp.
Gates
NixOS
linux-primary, bundledapps/mac/Fonts,FLASHTEX_TFM_DIRS=public/lm:jknappen/ec:public/amsfonts/symbols,CARGO_BUILD_JOBS=4. Zerofont-failure diagnostics (
font_unavailable,required_metrics_unavailable,ec_metrics_unavailable,font_outline_substituted,tfm_missing,math_font_unavailable) — notzero diagnostics of any kind;
math_resource_profileandmath_glyph_unmappedare informational and unchanged.crates/render-pipelinecargo test --release --no-fail-fast--features run-in-headings(needs the re-pin)fixtures/real-worlddocumentsplain-articlep2 words within 0.01 bp 68 → 138;lmodern-reportp2 max |dx| 38.33 → 0.01, p3 27.28 → 7.24;enumitem-worksheetp2 390.22 → 338.87;listings-manualp3 median dx −18.76 → −9.51;hyperref-tocp2 one more word aligns), 7 unchangedTwo pages that these changes move also shift vertically on constructs they do
not touch (
plain-articlep2 max |dy| 46.08 → 50.07,enumitem-worksheetp2 103.40 → 105.39). Both pages are already hundreds of bp from the reference
because of unimplemented constructs above them; the horizontal geometry those
changes own improves on both.
New tests:
tests/sectioning_depth.rs,tests/description_list.rs,tests/baselinestretch.rs,tests/run_in_headings.rs. Every expectedcoordinate in them is the pdflatex geometry of the matching reproducer, read
with
tools/visual-oracle/pdftext.py; the oracle is never run from a test.Provenance
pdflatex is an oracle only and is never in the product path. No committed
MacTeX-generated reference or sidecar was regenerated or overwritten. The one
new reference produced for this work (a local
\subparagraphprobe) was madewith TeX Live 2025 (
pdfTeX 3.141592653-2.6-1.40.27,SOURCE_DATE_EPOCH=0 FORCE_SOURCE_DATE=1, two passes), is labelled as suchand is not committed.
Not in this PR
abstract(#258 rank 1, the highest-frequency of the lot) is not fixedhere. It needs a capability
paragraph_blockdoes not have — a paragraph setat a size other than
\normalsizewith that size's own leading (ithard-codes
body_size_pt/baselineskip_pt;typeset/footnotes.rsis theonly existing precedent) — plus
quotation's\listparindent 1.5emevaluated in
\small's own\fontdimen6, and thecenter/quotation\@list<i>skips as\smallredefines them. pdflatex's own vertical listfor
min-abstract(\showoutput, TeX Live 2025) gives the exact targets:crates/title-layout/src/abstract_block.rsalready models most of this(
layout_abstract), but that crate is not a dependency of this one and itsown docs note that
\listparindentis not measured there. Wiring it in (ortranscribing its arithmetic against the vendored
document-style, whichalready exposes
list_level,font_sizeandSkip::addvspace) is thebounded next step.