Skip to content

render-pipeline: description is a \list (topsep/partopsep, hanging indent, bold label) - #401

Closed
GoKubar wants to merge 1 commit into
lane/nixos-vertical-drift-brokenpenaltyfrom
lane/nixos-vertical-drift-description
Closed

GoKubar wants to merge 1 commit into
lane/nixos-vertical-drift-brokenpenaltyfrom
lane/nixos-vertical-drift-description

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Stacked on #400 (lane/nixos-vertical-drift-brokenpenalty): the two changes are independent in intent but share typeset.rs hunks, so this branch contains both commits and the base is #400's branch. Review the second commit only.

render-pipeline: description is a \list (topsep/partopsep, hanging indent, bold label)

description was missing from the four hard-coded lists of list environments
in adapter.rs (list_stack_at, list_env_after_begin, gap_has_list_end,
list_end_adjust/list_end_skip), so an \item[...] of one got no \list
treatment at all: no \partopsep when the environment opened in vertical mode,
no \@endparenv skip at \end{description}, no \leftmargin hanging indent,
no \itemindent, and a medium-weight label.

article.cls builds it exactly like itemize:

\newenvironment{description}
  {\list{}{\labelwidth\z@ \itemindent-\leftmargin
           \let\makelabel\descriptionlabel}}{\endlist}
\newcommand*\descriptionlabel[1]{\hspace\labelsep \normalfont\bfseries #1}

so the four things that follow are now all implemented: the class list skips,
\labelwidth\z@ (a short label is never padded out), \itemindent-\leftmargin
(the item's first line is flush at the margin, continuation lines hang in), and
\descriptionlabel's \labelsep + \bfseries.

Oracle evidence (TeX Live 2025 pdflatex, oracle only). A probe with two
wrapping items and a one-line item, before -> after, against the reference:

first item baseline   -2.99 bp (the missing \partopsep, 3 pt)  ->  0.00
paragraph after the list  -14.95 bp (that plus the whole
                          missing \@endparenv skip, 12 pt)     ->  0.00
label x               -5.46 bp (no \descriptionlabel \labelsep) ->  0.00
continuation line x  -27.27 bp (no \leftmargin)                ->  0.00

The same -2.99 bp and -27.28 bp are the two largest deltas on page 3 of
fixtures/real-world/lmodern-report; that page is now exact.

A second defect surfaced while measuring: a multi-word label was shaped as one
run, so the gap between its words was the T1 visible-space glyph's advance
(6.27 bp for \bfseries Latin Modern at 11 pt) rather than \fontdimen2
(4.18 bp), pushing everything after the label 2.1 bp right. label_box now
builds the label the way number_box already built amsmath tags — one shaped
run per word, joined by TeX's interword glue — and the two share word_box.

Real-world corpus (22 documents, tools/visual-oracle/rank.py), on top of the
\brokenpenalty fix:

dy   <= 0.5 bp   70.4% -> 72.0%
both <= 0.5 bp   63.8% -> 65.3%
dx   <= 0.5 bp   84.5% -> 85.2%

Per fixture, only the four description documents move: lmodern-report
dy 81.8 -> 100.0 / both 81.1 -> 98.9, enumitem-worksheet dx 49.5 -> 51.3,
listings-manual dx 42.7 -> 43.6, plain-article dx 83.4 -> 89.6. plain-article's
dy reads 50.3 -> 47.9: its page 2 already carried a pre-existing glue-shrink
ramp (our page 2 is over-full and shrinks where pdflatex's is \raggedbottom
and stretches, because we break three lines later at \section{Cost Comparison}), and the old description skips happened to cancel part of it.
The ramp is unchanged by this commit — measured identical on the previous
binary — and the page-break difference is a separate defect. Page counts are
unchanged everywhere (20/22).

Gates: cargo test --release --no-fail-fast on crates/render-pipeline green,
new tests/description_env.rs; amsmath 59/59, tabular 106/106, HW1 and HW2
3 pages / 0 errors, zero font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-vertical-drift, linux-primary)
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

…dent, bold label)

`description` was missing from the four hard-coded lists of list environments
in `adapter.rs` (`list_stack_at`, `list_env_after_begin`, `gap_has_list_end`,
`list_end_adjust`/`list_end_skip`), so an `\item[...]` of one got no `\list`
treatment at all: no `\partopsep` when the environment opened in vertical mode,
no `\@endparenv` skip at `\end{description}`, no `\leftmargin` hanging indent,
no `\itemindent`, and a medium-weight label.

article.cls builds it exactly like `itemize`:

    \newenvironment{description}
      {\list{}{\labelwidth\z@ \itemindent-\leftmargin
               \let\makelabel\descriptionlabel}}{\endlist}
    \newcommand*\descriptionlabel[1]{\hspace\labelsep \normalfont\bfseries #1}

so the four things that follow are now all implemented: the class list skips,
`\labelwidth\z@` (a short label is never padded out), `\itemindent-\leftmargin`
(the item's first line is flush at the margin, continuation lines hang in), and
`\descriptionlabel`'s `\labelsep` + `\bfseries`.

Oracle evidence (TeX Live 2025 pdflatex, oracle only). A probe with two
wrapping items and a one-line item, before -> after, against the reference:

    first item baseline   -2.99 bp (the missing \partopsep, 3 pt)  ->  0.00
    paragraph after the list  -14.95 bp (that plus the whole
                              missing \@endparenv skip, 12 pt)     ->  0.00
    label x               -5.46 bp (no \descriptionlabel \labelsep) ->  0.00
    continuation line x  -27.27 bp (no \leftmargin)                ->  0.00

The same -2.99 bp and -27.28 bp are the two largest deltas on page 3 of
`fixtures/real-world/lmodern-report`; that page is now exact.

A second defect surfaced while measuring: a multi-word label was shaped as one
run, so the gap between its words was the **T1 visible-space glyph's** advance
(6.27 bp for `\bfseries` Latin Modern at 11 pt) rather than `\fontdimen2`
(4.18 bp), pushing everything after the label 2.1 bp right. `label_box` now
builds the label the way `number_box` already built amsmath tags — one shaped
run per word, joined by TeX's interword glue — and the two share `word_box`.

Real-world corpus (22 documents, `tools/visual-oracle/rank.py`), on top of the
`\brokenpenalty` fix:

    dy   <= 0.5 bp   70.4% -> 72.0%
    both <= 0.5 bp   63.8% -> 65.3%
    dx   <= 0.5 bp   84.5% -> 85.2%

Per fixture, only the four `description` documents move: lmodern-report
dy 81.8 -> 100.0 / both 81.1 -> 98.9, enumitem-worksheet dx 49.5 -> 51.3,
listings-manual dx 42.7 -> 43.6, plain-article dx 83.4 -> 89.6. plain-article's
dy reads 50.3 -> 47.9: its page 2 already carried a pre-existing glue-shrink
ramp (our page 2 is over-full and shrinks where pdflatex's is `\raggedbottom`
and stretches, because we break three lines later at `\section{Cost
Comparison}`), and the old `description` skips happened to cancel part of it.
The ramp is unchanged by this commit — measured identical on the previous
binary — and the page-break difference is a separate defect. Page counts are
unchanged everywhere (20/22).

Gates: `cargo test --release --no-fail-fast` on crates/render-pipeline green,
new `tests/description_env.rs`; amsmath 59/59, tabular 106/106, HW1 and HW2
3 pages / 0 errors, zero font-FAILURE diagnostics.

Implementation-Agent: Claude Opus 5 (lane nixos-vertical-drift, linux-primary)
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
@GoKubar
GoKubar deleted the branch lane/nixos-vertical-drift-brokenpenalty September 14, 2026 16:10
@GoKubar GoKubar closed this Sep 14, 2026
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Closed automatically when I deleted its base branch on merging #400 — my mistake, not a judgement on the change. The description-as-\list commit df78bb63 is not lost: it rode into main inside #405, which I retargeted to main and merged. Verified before merging that #400's \brokenpenalty work was not re-applied (zero occurrences in the net diff against main) and that crates/render-pipeline was 267 passed / 0 failed on the merge result.

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