Skip to content

render-pipeline: align short-then-tall rows fall into opened-up lineskip mode (#814) - #822

Merged
d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead-2/align-tall-row
Sep 17, 2026
Merged

d-q222 merged 1 commit into
mainfrom
agent/daniel-muse-lead-2/align-tall-row

Conversation

@d-q222

@d-q222 d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A short row above a \frac-containing (or otherwise tall) row in align/align*/gather stayed in baselineskip mode where pdflatex, whose \openup\jot also advances \lineskiplimit, has already fallen into lineskip mode. Fixed by folding the missing glue into the upper row's after-skip exactly when the opened-up limit (not the page's own) puts the pair in lineskip mode.
  • Correction made during review: the lane's fix applied this unconditionally to every RowsEnv including EqnArray, using amsmath-specific constants that don't describe eqnarray's actual (never-opened-up) behavior. Added an explicit !is_eqnarray guard — verified the existing eqnarray tests still pass with it.

Produced by a supervised Muse Contributor lane (align-tall-row), reviewed, corrected, and independently re-tested before publishing.

Test plan

  • cargo build --release --locked clean
  • Full flashtex-render-pipeline suite green, independently re-run on the exact published tree (on top of main's current eqnarray fix), including the 2 new align_tall_row tests and all 4 eqnarray tests (--include-ignored)

🤖 Generated with Claude Code

…kip mode (#814)

A short row above a row containing a `\frac` (or other tall construct) in
`align`/`align*`/`gather` stayed in baselineskip mode (14.944bp gap) where
pdflatex, whose `\openup\jot` also advances `\lineskiplimit`, has already
fallen into lineskip mode (18.6009bp): the interline glue between these
rows was laid against the page's own `\lineskiplimit` (0pt), not amsmath's
opened-up one. Tall-above-short already matched (19.1876pt), since that
direction gives negative candidate glue, below either limit.

Folds the missing difference into the upper row's after-skip exactly when
the opened-up limit -- not the page limit -- puts the pair in lineskip
mode.

Found during independent review: the lane's own fix applied this
correction unconditionally to every `RowsEnv`, including `EqnArray`, using
amsmath's `\baselineskip+\jot`/`\lineskip+\jot` constants. `eqnarray` never
runs `\openup` (a separate, already-fixed issue: it gets its `\jot` from an
explicit per-row `\noalign` vskip, not an opened-up lineskip threshold), so
those constants don't describe its actual behavior. The lane's own test
suite happened not to exercise this interaction (its base predated the
eqnarray fix merging into main), so it passed by coincidence rather than
by being conditioned correctly. Added an explicit `!is_eqnarray` guard;
verified the existing eqnarray tests (including the already-fixed
tall-then-short case) still pass unchanged with the guard in place.

Verified: cargo build --release --locked clean; full flashtex-render-pipeline
suite green (independently re-run on the exact published tree, on top of
main's current eqnarray fix), including the 2 new align_tall_row tests and
all 4 eqnarray tests (--include-ignored).

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane align-tall-row, slice 1)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
Reviewed-by: daniel-muse-lead-2 (Claude Sonnet)
Muse-Lane-Head: a03798aa08b76b08f6a6d48189b557c346adb972
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent Opus review of 6095daaa, APPROVE. The reviewer measured pdflatex row baselines with \pdfsavepos across 17 documents; every alignment case now matches within 0.0002pt, eqnarray is untouched, and no corpus digests change (all 22 real fixtures produce identical display lists). Merging in batch U.

Review: PR #822 (head 6095daa) — align short-then-tall rows fall into opened-up lineskip mode (#814)

Independent read-only review. Oracle: pdflatex (TeX Live, \pdfsavepos + \write of
\pdflastypos on each row, exact sp values, so the gaps below are pdflatex's own
baseline-to-baseline distances, not bbox estimates). Every document was rendered through
the pipeline at this head and at the merge base (origin/main) for comparison.

Material findings

None.

Oracle verification (all values TeX pt; bp = pt/1.00375)

crates/render-pipeline/src/typeset.rs:6014-6043 correction, article 10pt unless noted.
PR = this head, base = merge base, pdflatex = \pdflastypos difference.

case pdflatex PR base
align* short→\frac 18.6707 (18.6009bp) 18.6706 15.0000
align* \frac→short 19.2595 (19.1875bp) 19.2595 19.2595
align* \frac→\frac 21.9301 21.9301 21.9301
align* 3 rows short/\frac/short 18.6707, 19.2595 18.6706, 19.2595 —
numbered align short→\frac / \frac→short 18.6707 / 19.2595 18.6706 / 19.2595 15.0000 / 19.2595
align with \tag{A} on row 1 18.6707 18.6706 15.0000
gather* / gather short→\frac 18.6707 18.6706 15.0000
multline short→\frac / \frac→short / 3 rows 18.6707 / 19.2595 / 18.6707,19.2595 same to 1e-4 15.0000 / 19.2595
alignat*, flalign*, split, aligned, gathered short→\frac 18.6707 18.6706 15.0000 (aligned/gathered/split already 18.6706)
11pt / 12pt align* short→\frac 20.2023 / 21.6348 20.2023 / 21.6348 16.6000 / 21.6348
short→\sqrt, short→\sum, short→\hat{\hat{}}, short→\big(, short→\tfrac, sub/superscript rows 17.4104 / 18.1001 / 19.8223 / 16.1001 / 15.0000 / 16.2401 all within 0.0002 several were 15.0000
eqnarray* short→\frac 17.0151 (16.9516bp) 17.0151 17.0151

All PR values are within 0.0002pt (0.0002bp) of pdflatex — far inside the 0.01bp gate —
including the boundary cases the guard has to get right: two strut-sized short rows stay
at exactly 15.0000pt (baselineskip mode, g == \jot), and \tfrac stays at 15.0000pt.
eqnarray is genuinely untouched: identical before/after and equal to pdflatex, and the
!is_eqnarray guard is the only thing standing between the two (--test eqnarray green).

The condition g >= limit && g < limit + JOT - 1e-9 is TeX's own strict < against the
opened-up \lineskiplimit, with the lower bound preserving the already-correct
below-page-limit (negative glue) path. The folded amount
prevdepth + (\lineskip+\jot) + height - (\baselineskip+\jot) is exactly the difference
between the two modes, so it stays additive with anything else already in vskips[i-1].

Corpus / baseline digests

No perf-bench baseline re-record is needed. Alignment-bearing corpus inputs:

  • fixtures/real-world/math-sheet/main.tex (align 20-25, align* 29-34, gather 84-88)
  • fixtures/real-world/ps-calculus/main.tex (align 60-65, align* 76-82, align* 148-151)
  • fixtures/real-world/lecture-notes/main.tex (align* 113-118)
  • fixtures/real-world/thesis-chapter/sections/method.tex (inline "align" prose only)
  • the synthetic math corpus, crates/perf-bench/src/corpus.rs:116 (align with \sum/\prod\left(\frac{}{}\right) rows) and :139 (gather)

In every one of them the tall rows are adjacent to other tall rows (negative interline
glue, already lineskip mode) or all rows are short, so the new branch never fires. Rather
than rely on that reading, I rendered all 22 fixtures/real-world projects plus a
document containing the two synthetic corpus alignment blocks through flashtex-render --v2 at this head and at the merge base: all 25 display lists are byte-identical
(hw1 1.15MB, hw2 1.03MB, math-sheet, ps-calculus, lecture-notes, thesis-chapter
included). Since the perf-bench digests are hashes of the reply/PDF bytes
(crates/perf-bench/src/measure.rs:361,486), unchanged display lists mean unchanged
digests.

Non-blocking notes

  1. crates/render-pipeline/tests/align_tall_row.rs:24 — the "## Oracle" line reads
    "tall-then-short 19.1875pt"; that number is bp (pdflatex's pt value is 19.2595).
    The sibling number on the same line is correctly labelled bp.
  2. crates/render-pipeline/tests/align_tall_row.rs:35-38 — EXPECTED_TALL_THEN_SHORT_BP = 19.1876 is the pipeline's own output; pdflatex is 19.18754bp, i.e. 19.1875. Within
    the 0.01 tolerance either way, but the comment claims agreement "to the fourth decimal"
    when the fourth decimal is where they differ. Pin the pdflatex value.
  3. Coverage: only align* short→tall and tall→short are pinned. \frac→\frac, numbered
    align, gather*/gather, multline, alignat, flalign and the 11pt/12pt sizes
    all changed behaviour here (see the table) and none of them is pinned by a test; a
    future regression in, say, multline would be caught by nothing. Cheap to add: the
    same helper with a different body/environment.
  4. Issue render-pipeline: align* short row followed by a \frac row is 14.944bp apart, pdflatex 18.6009bp #814's secondary items are not addressed by this PR and remain open:
    tests/eqnarray.rs:71 still uses TOL = 0.5 bp; tests/eqnarray.rs:292,312 still
    label 15.00pt as "15.00 bp" (it is 14.944bp); there are still no pins for numbered
    eqnarray (18.2909bp) or eqnarray short→\frac (16.9515bp — I measured 17.0151pt =
    16.9516bp, pipeline agrees exactly); and tests/eqnarray.rs:63-64 still claims
    typeset::eqnarray_tests "covers ... that tall-row divergence" while that module
    (src/typeset.rs:11003) has only column/centering/fleqn tests, no tall-row case.
    Worth either folding in or splitting to a follow-up issue so render-pipeline: align* short row followed by a \frac row is 14.944bp apart, pdflatex 18.6009bp #814 is not closed with
    them silently dropped.
  5. Pre-existing, unrelated to this PR but found while probing: \\[<len>] extra row space
    is dropped entirely in amsmath alignments. x &= y \\[2pt] c &= d is 17.0000pt in
    pdflatex, 15.0000pt both at this head and at the merge base; \\[6pt] likewise
    (21.0000 vs 15.0000). Not a regression — flagging for a separate issue.
  6. Pre-existing: \intertext blocks still drift. align* short row, wrapped \intertext
    paragraph containing inline \fracs, then a \frac row measures 65.0703pt in pdflatex;
    this head gives 64.0150 (merge base 62.0000), so the PR halves the error but does not
    remove it, and the paragraph-internal gap inside \intertext is 12.0000 vs pdflatex
    14.0151 both before and after. Note that the new loop iterates over extents, which
    also holds \intertext paragraph lines — those live in a \vbox with
    \normalbaselines in TeX, so applying the opened-up limit there is not strictly right.
    I could not construct a case where it makes a real document worse (the probe cases came
    out identical at both revisions), so this is a robustness note, not a defect: a comment
    in the loop saying extents may contain \intertext lines, or restricting the loop to
    row indices, would make the intent explicit.

Tests run

From crates/render-pipeline, nice -n 15 env CARGO_BUILD_JOBS=3 CARGO_TARGET_DIR=$HOME/flashtex-wt/review-target cargo test --locked --test <filter>:

  • --test align_tall_row — 2 passed (the PR's new file)
  • --test eqnarray — 4 passed
  • --test display_math — 1 passed
  • --test amsmath_openup_jot — 1 passed
  • --test display_placement — 1 passed

Plus, outside the test suite: 17 pdflatex oracle documents measured with \pdfsavepos, the
same documents rendered through the pipeline at this head and at the merge base, and the
25 corpus/fixture display-list comparisons described above.

VERDICT: APPROVE

@d-q222
d-q222 merged commit b8d8d6e into main Sep 17, 2026
17 of 22 checks passed
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