Skip to content

render-pipeline: \brokenpenalty after a line the paragraph broke at a discretionary - #400

Merged
GoKubar merged 1 commit into
mainfrom
lane/nixos-vertical-drift-brokenpenalty
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
lane/nixos-vertical-drift-brokenpenalty

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

render-pipeline: \brokenpenalty after a line the paragraph broke at a discretionary

TeX appends \interlinepenalty + \clubpenalty + \widowpenalty + \brokenpenalty
after each line of a paragraph (§890 if disc_break then pen:=pen+broken_penalty);
the page builder had every term but \brokenpenalty (latex.ltx sets it to 100),
so a page could break for free right after a hyphenated line.

Oracle evidence (\showoutput on fixtures/real-world/lmodern-report, TeX Live
2025 pdflatex, oracle only): page 1's vertical list carries \penalty 100 after
the line ending Man-, and pdflatex breaks one line later, at badness 2 with
the page shrunk (\vbox(650.43001+0.0)x469.75502, glue set - 0.26439), rather
than at the hyphenated break whose badness alone is 1. Without the penalty this
crate took the cheaper-looking earlier break, every line of page 2 landed one
\baselineskip (13.55 bp) low, and page 1 stood at its natural height instead
of shrinking (the +1.83…+2.33 bp drift down that page).

With the penalty the page builder now reports natural 652.76429 and glue-set
ratio -0.26440 for that page, against pdflatex's 652.7643 / -0.26439.

Real-world corpus (22 documents, word positions vs the pinned pdflatex
references, tools/visual-oracle/rank.py):

dy  <= 0.5 bp   65.2% -> 70.4%
both <= 0.5 bp  58.7% -> 63.8%
dx  <= 0.5 bp   84.5% -> 84.5% (unchanged)

lmodern-report alone: dy 26.4% -> 81.8%, both 26.4% -> 81.1%. No other fixture
moves in either direction; page counts are unchanged everywhere.

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

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

… discretionary

TeX appends `\interlinepenalty + \clubpenalty + \widowpenalty + \brokenpenalty`
after each line of a paragraph (§890 `if disc_break then pen:=pen+broken_penalty`);
the page builder had every term but `\brokenpenalty` (latex.ltx sets it to 100),
so a page could break for free right after a hyphenated line.

Oracle evidence (`\showoutput` on `fixtures/real-world/lmodern-report`, TeX Live
2025 pdflatex, oracle only): page 1's vertical list carries `\penalty 100` after
the line ending `Man-`, and pdflatex breaks one line *later*, at badness 2 with
the page shrunk (`\vbox(650.43001+0.0)x469.75502, glue set - 0.26439`), rather
than at the hyphenated break whose badness alone is 1. Without the penalty this
crate took the cheaper-looking earlier break, every line of page 2 landed one
`\baselineskip` (13.55 bp) low, and page 1 stood at its natural height instead
of shrinking (the +1.83…+2.33 bp drift down that page).

With the penalty the page builder now reports natural 652.76429 and glue-set
ratio -0.26440 for that page, against pdflatex's 652.7643 / -0.26439.

Real-world corpus (22 documents, word positions vs the pinned pdflatex
references, `tools/visual-oracle/rank.py`):

    dy  <= 0.5 bp   65.2% -> 70.4%
    both <= 0.5 bp  58.7% -> 63.8%
    dx  <= 0.5 bp   84.5% -> 84.5% (unchanged)

lmodern-report alone: dy 26.4% -> 81.8%, both 26.4% -> 81.1%. No other fixture
moves in either direction; page counts are unchanged everywhere.

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

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
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