Skip to content

a display chooses between the long and the SHORT skips, as tex.web:22580 does - #684

Merged
tannevaled merged 2 commits into
mainfrom
display-glue
Nov 4, 2026
Merged

tannevaled merged 2 commits into
mainfrom
display-glue

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Closes #683 — the first attributable cause of the page bias (#622).

The defect

The short pair of display skips was never selected. tex.web:22578-22585:

if (d+s <= pre_display_size) or l then   {not enough clearance}
  begin g1:=above_display_skip_code; g2:=below_display_skip_code; end
else
  begin g1:=above_display_short_skip_code; g2:=below_display_short_skip_code; end

The short pair is for a display whose left edge falls to the right of where the
previous line ends — they do not collide, so little space is needed. A centred display
after an ordinary short line is exactly that, and it is the common case.

Measured, baseline to baseline

\noindent Ligne avant le display.
\[E = 1\]
\noindent Ligne apres le display.
au-dessus en dessous
tectonic 11.96 17.93
nous, avant 21.92 21.92
nous, après 11.96 17.93

Exact on both sides. A document of 40 displays went 6 pages → 5, which is
tectonic's 5; the 80-paragraph prose control stays at 6, also tectonic's.

Corpus A/B — and what the headline hides

Control 712e574, treatment 2637a60:

étiquette Σ|·| biais exacts médiane |écart|
avant 276 +50 38 1.0
après 275 +35 39 0.0

The bias — the figure #622 is about — improves by 15 pages, and the median absolute
deviation reaches 0.

Σ|·| moves by one, and that is the number to read. All 14 movers got shorter, by
the right amount; that helps the papers that were too long and hurts the ones that were
already too short:

8 rapprochés 2305.01199 +2→+1, 2311.02037 +3→+2, 2311.08855 +1→0, 2311.09365 +2→+1, 2312.02121 +1→0, 2406.15398 +2→+1, 2407.21763 +2→+1, 2408.08199 +1→0
6 éloignés 2206.05540 0→−1, 2403.10748 0→−1, 2208.08532 −2→−3, 2304.06058 −3→−4, 2311.00084 −1→−2, 2407.18384 −9→−11

Two documents that were exact are no longer. I am not reporting "+50 → +35" without
this table: the net gain of 1 on Σ hides eight improvements and six regressions.

Why that is a reason to merge, not to revert

The spacing now matches the reference to the hundredth of a point on a probe where
nothing else is in play. The six that got worse were compensating: they are all
papers we already set too short, and our surplus display glue was partly cancelling a
different deficit. Removing the surplus does not create their problem, it uncovers
it — and it is now measurable on its own, which it was not while two errors were
subtracting.

The render channel says the same: 73 of 154 render differently, 59 of them invisible to
a page count.

The existing test asserted one branch without knowing there were two

TestDisplaySkipsAroundDisplay used before $$x$$ after — a short line and a centred
display, i.e. the short branch — and asserted 10pt there, freezing the defect. It now
uses a display wide enough to reach back under the preceding line, which is the long
branch it meant to exercise, and the short branch has a test of its own.

⚠ A long preceding paragraph does not produce the long branch, and the comment says
so: the quantity TeX measures is that paragraph's last line, and a paragraph long
enough to wrap ends on a short remainder. Widening the display moves the other half of
the same comparison.

NOT DONE HERE

  • \predisplaysize is computed where it is needed, not exposed as a register, so
    \the\predisplaysize is still undefined.
  • displayLeftEdge reads the centred case, which is what \[…\] and equation
    produce. A display shifted by \displayindent (fleqn) needs its own left edge.
  • The six documents this uncovers are a separate defect, in the short direction.

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 4, 2026 21:49
…580 does

The short pair was never selected, and that cost 13.95pt on every display.

    if (d+s <= pre_display_size) or l then   {not enough clearance}
      begin g1:=above_display_skip_code; g2:=below_display_skip_code; end
    else
      begin g1:=above_display_short_skip_code; g2:=below_display_short_skip_code; end

The short pair is for a display whose left edge falls to the RIGHT of where the
previous line ends: the two do not collide, so little space is needed. A centred
display after an ordinary short line is exactly that case, and it is the common one.

Measured baseline to baseline across one display between two text lines:

                   au-dessus   en dessous
    tectonic           11.96       17.93
    nous, avant        21.92       21.92
    nous, apres        11.96       17.93

Exact, to the hundredth of a point, on both sides. 40 displays in a document went
from 6 pages to 5, which is tectonic's 5; the prose control stays at 6, also
tectonic's.

\predisplaysize is new here and follows tex.web:21781-21813 including its two
details that are easy to miss:

- the running sum stops at the last VISIBLE node. A line ends with \parfillskip and
  text does not "reach" trailing glue; counting it would make every line full-width
  and select the long pair always — the original defect under another name.
- only INFINITE stretch poisons the sum. Ordinary interword glue stretches finitely
  and must pass, or every justified line would report \maxdimen. The reference
  settles it: tectonic prints \predisplaysize as 48.37pt and 93.77pt on two ordinary
  lines, finite values where a poisoned sum shows 16383.99998pt.
- it starts at shift_amount + 2*quad, and the two quads are not decorative: without
  them a line reads shorter than it is and the short pair is chosen too often, the
  error in the direction that TIGHTENS the page.

An existing test asserted one branch without knowing there were two.
TestDisplaySkipsAroundDisplay used `before $$x$$ after`, which takes the SHORT
branch, and asserted 10pt there — freezing the defect. It now uses a display wide
enough to reach back under the preceding line, which is the long branch it meant to
test, and the short branch has a test of its own. A long preceding PARAGRAPH does not
produce the long branch, and the comment says so: the quantity TeX measures is that
paragraph's last line, and a paragraph long enough to wrap ends on a short remainder.

NOT DONE HERE: \predisplaysize is computed where it is needed rather than exposed as
a register, so \the\predisplaysize is still undefined; and displayLeftEdge reads the
CENTRED case, which is what \[…\] and equation produce. A display shifted by
\displayindent (fleqn) would need its own left edge.

Co-Authored-By: Claude Opus 5 <[email protected]>
@tannevaled
tannevaled merged commit 47aabb0 into main Nov 4, 2026
18 checks passed
@tannevaled
tannevaled deleted the display-glue branch November 4, 2026 21:28
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.

Every display equation contributes 13.1pt too much vertical glue (the first attributable cause of #622)

1 participant