Skip to content

render-pipeline: description is a \list, so its bodies hang at \leftmargin - #396

Closed
GoKubar wants to merge 1 commit into
mainfrom
lane/nixos-gfxsec/description-list
Closed

GoKubar wants to merge 1 commit into
mainfrom
lane/nixos-gfxsec/description-list

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What

The pipeline's list scanners knew itemize, enumerate and thebibliography only, so a \begin{description} item got an empty margin stack: \@totalleftmargin 0, no \topsep/\itemsep, no label geometry. Its body — first line and continuation lines alike — was set at the plain text margin.

article.cls lines 400-404 build description from the same \list{}{...} with the same class \leftmargin<i>; the three differences are \labelwidth\z@, \itemindent-\leftmargin and \descriptionlabel (\hspace\labelsep\normalfont\bfseries #1). So continuation lines hang at \leftmargin while the first line is pulled back out and the term sets flush at the enclosing margin, in bold.

Second fix, required by the first: \item labels are now set the way \sbox\@tempboxa{\makelabel{#1}} does — each word its own text box, the gaps TeX's interword glue at natural width. Shaping "A much longer term" as one run resolves U+0020 through the face's cmap, and in T1 that slot is visiblespace: 1.91 bp per gap wider than \fontdimen2 on ecbx1000. number_box already avoided this for amsmath tags; every multi-word \item[...] label carried it.

Files touched

  • crates/render-pipeline/src/adapter.rs (LIST_ENVS, ListGeom::description)
  • crates/render-pipeline/src/typeset.rs (ListBox, LabelBox, list_box, label_box)
  • crates/render-pipeline/tests/description_list.rs (new)

No crates/render-pipeline/vendor/* change; no compiler-side change; no vendor re-pin required.

Oracle evidence

pdflatex TeX Live 2025 on fixtures/divergence-probes/min-description:

before after
continuation line x 72.000 vs ref 96.907 (dx −24.907 bp) 96.907 (exact)
paragraph below the list 11.955 bp high exact
first item baseline −1.992 bp exact
words within 0.5 bp in x and y 5 / 38 38 / 38

Corpus

22 real documents vs pdflatex, tolerance 0.5 bp:

before after
dx 84.47% 85.19%
dy 65.21% 66.81%
both 58.67% 60.23%
page counts 20/22 20/22

Only the four fixtures that use description move:

fixture dx dy both
enumitem-worksheet 49.46 → 51.25 5.38 → 5.38 5.38 → 5.38
listings-manual 42.71 → 43.59 3.94 → 3.94 2.19 → 2.19
lmodern-report 94.99 → 98.92 26.37 → 44.76 26.37 → 44.38
plain-article 83.44 → 89.61 50.32 → 47.89 41.23 → 38.80

The one number that falls

plain-article's dy is an artefact of measuring absolute position on a page that is still wrong for other reasons. Every local spacing on that page improves:

page-2 landmark before after
description item 1 / 2 / 3 dy +3.17 / +2.74 / +2.30 −0.48 / −0.74 / −1.00
description item 1 / 2 / 3 dx −4.98 / −4.98 / −4.98 0.00 / 0.00 / 0.00
\section below the list +1.93 −1.23
quote gap error −2.18 −1.30

What the metric loses is 25 words whose accumulated offset happened to land inside 0.5 bp before. The residual page-wide vertical constant is the vertical-drift lane's, not this change's.

Gates

cargo test --release --no-fail-fast with FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRS set:

  • crates/render-pipeline 254 passed / 0 failed / 2 ignored, plus the new description_list test
  • crates/class-geometry 4 passed / 0 failed
  • crates/compiler 572 passed / 0 failed / 4 ignored
  • amsmath 59/59, tabular 106/106
  • HW1 and HW2: 3 pages, 0 errors, 0 font-FAILURE diagnostics

Coordination

Another lane is working the vertical origin drift in lmodern-report/plain-article. This PR touches adapter.rs, typeset.rs and one new test file. It does not touch the per-page vertical constant; the plain-article dy column above is explained in full under "the one number that falls". It is independent of #395 (secnumdepth), which touches only the secnumdepth binding in adapter.rs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…leftmargin`

The pipeline's list scanners knew `itemize`, `enumerate` and
`thebibliography` only, so a `\begin{description}` item got an *empty*
margin stack: `\@totalleftmargin` 0, no `\topsep`/`\itemsep`, no label
geometry. Its body — first line and continuation lines alike — was set at
the plain text margin.

article.cls lines 400-404 build `description` from the same `\list{}{...}`
with the same class `\leftmargin<i>`; the three differences are
`\labelwidth\z@`, `\itemindent-\leftmargin` and `\descriptionlabel`
(`\hspace\labelsep\normalfont\bfseries #1`). So the continuation lines hang
at `\leftmargin` while the first line is pulled back out and the term sets
flush at the enclosing margin, in bold, with `\descriptionlabel`'s own
`\hspace\labelsep` cancelling `\@item`'s `\hskip-\labelsep`.

`\item` labels are now set the way `\sbox\@tempboxa{\makelabel{#1}}` does:
each word its own text box, the gaps TeX's interword glue at natural width.
Shaping `"A much longer term"` as one run resolves `U+0020` through the
face's cmap, and in T1 that slot is `visiblespace` — 1.91 bp per gap wider
than `\fontdimen2` on `ecbx1000`. `number_box` already avoided this for
amsmath tags; every multi-word `\item[...]` label carried it.

Measured against pdflatex (TeX Live 2025) on
`fixtures/divergence-probes/min-description`: before, the continuation line
was at x 72.000 against the reference's 96.907 (**dx -24.907 bp**) and the
paragraph after the list was **11.955 bp** high. After, all 38 words on the
page are within 0.5 bp in x and y — the probe is exact.

Corpus (22 real documents vs pdflatex, tolerance 0.5 bp):
dx 84.47% -> 85.19%, dy 65.21% -> 66.81%, both 58.67% -> 60.23%, page
counts 20/22 unchanged. The four fixtures that use `description` are the
only ones that move:

  enumitem-worksheet  dx 49.46 -> 51.25   dy  5.38 ->  5.38
  listings-manual     dx 42.71 -> 43.59   dy  3.94 ->  3.94
  lmodern-report      dx 94.99 -> 98.92   dy 26.37 -> 44.76   both 26.37 -> 44.38
  plain-article       dx 83.44 -> 89.61   dy 50.32 -> 47.89   both 41.23 -> 38.80

`plain-article`'s `dy` is the one number that falls, and it is an artefact
of measuring absolute position on a page that is still wrong for other
reasons. Every *local* spacing on that page improves: the three description
items go from dy +3.17/+2.74/+2.30 to -0.48/-0.74/-1.00, the heading below
the list from +1.93 to -1.23, and the `quote` gap error from -2.18 to
-1.30. What the metric loses is 25 words whose accumulated offset happened
to land inside 0.5 bp before. The residual page-wide vertical constant is
the vertical-drift lane's, not this change's.

Gates: `cargo test --release --no-fail-fast` on render-pipeline 254 passed
/ 0 failed / 2 ignored (plus the new `description_list` test),
class-geometry 4/0, compiler 572/0/4; amsmath 59/59, tabular 106/106, HW1
and HW2 3 pages / 0 errors / 0 font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-graphics-sectioning, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #405, which landed the same thing while this was open — and did it more thoroughly. Closing rather than merging twice.

I rebased and re-measured against current main (fb79c646) before deciding. fixtures/divergence-probes/min-description is now exact on main: all 38 words within 0.5 bp in x and y. Everything this PR did is covered:

this PR on main
description in the list-environment scanners (\leftmargin hang) #405
\labelwidth\z@ + \itemindent-\leftmargin #405
bold \descriptionlabel #405
\topsep/\partopsep/\itemsep/\parsep + the closing \@endparenv skip #405
multi-word \item[...] label shaped as one run, so its gap used the T1 visiblespace advance instead of \fontdimen2 #405 found and fixed this independently

One thing was not covered, so I have split it out as #409: a description item whose body opens with a display (\item[Term] \[...\]). That line is built by display_opener_block, which still places the term at \leftmargin - \labelsep — dx +19.925 bp against pdflatex on all three words of the term. list_geometry already returns the innermost \leftmargin for exactly this; the call site was discarding it. #409 is two lines plus a test, and has no corpus movement (no real-world fixture has that shape), which I say plainly in its body.

No complaint about the overlap — #405 is the better version of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant