Skip to content

math-layout: size \big..\Bigg by the kernel's fixed lengths without amsmath - #239

Merged
GoKubar merged 1 commit into
mainfrom
agent/linux-big-delims/kernel-sizing
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/linux-big-delims/kernel-sizing

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

First, a correction to the brief I was given, because it would have cost another lane a day.

I was dispatched to fix the finding in #227's "out of scope" section — "TexMathMetrics always builds CmMathMetrics with ExtensionSizing::Fixed … cm::ExtensionSizing::Designs already models this; nothing selects it," with fixtures/real-world/math-sheet's \left[ at 39.42pt in pdfTeX against 42.00pt here.

That is already fixed on main, and it was already fixed in #227's own base. #204 merged as 619c192b at 2026-09-13T23:36:42Z; #227 branched from a1c651a2, which contains it (git merge-base --is-ancestor 619c192b a1c651a2 → yes). The note was written against stale code.

Verified three ways on main @ eea975c3:

  1. style::cmex_designs exists, TexMathMetrics::new takes it, and mathtex.rs:116 applies ExtensionSizing::Designs. Every delimiter path (delimiter_sizes, delimiter_extensible, extension_glyph, radical_sizes, large_operator) delegates to that same self.cm, so there is no second route.
  2. \fontname\textfont3 probed over 8 package sets × 3 body sizes under pdfTeX TL2025 reproduces render-pipeline: size family 3 as amsmath declares it, not sfixed*cmex10 #204's table exactly, including lmodern → lmex10 in either load order and [cmex10]{amsmath} → cmex10.
  3. The quoted measurement does not reproduce. math-sheet's \left[ is in an align*, i.e. display style; pdfTeX's box is (0.43799+25.84227)x5.77919 = 26.28026pt from \OMX/cmex/m/n/10.95. FlashTeX on main emits that delimiter at 10.95pt with box 26.28000pt, width 5.77919 — already exact, within the display list's 2^-20 bp tick. (39.42 is 2× the text-style box, 19.71019.)

So there was no extension-sizing bug left to fix. Sweeping 10/11/12pt × {none, amsmath, amsmath+lmodern} for \left[ ( \{ |, \Big/\Bigg and \sqrt against \showbox to find what is still wrong turned up the following instead.


What this PR fixes

make_big_delimiter implemented only amsmath's \bBigg@ (amsmath.sty 721-738): \vcenter to <factor>\big@size{} with \big@size = 1.2 × \Mathstrutbox@. That is correct when amsmath is loaded. The LaTeX kernel has its own, different definition (fontmath.ltx 513-520), and it is what a document without amsmath gets:

\big  -> \left<d>\vbox to  8.5pt{}\right.      \bigg -> \vbox to 14.5pt
\Big  -> \left<d>\vbox to 11.5pt{}\right.      \Bigg -> \vbox to 17.5pt

Two differences, not one:

  • the lengths are absolute, so they do not follow the body size;
  • the box is a \vbox (height pt, depth 0), not a \vcenter, so Rule 19's δ is max(pt − axis, axis) rather than half the target, and the result is floored at the vbox's own height.

The two rules coincide at 10pt and diverge at every other body size — which is why this survived: every 10pt comparison agrees, and the amsmath corpora load amsmath.

Measured against pdflatex (TeX Live 2025)

\showbox of \hbox{$\displaystyle\Big[$} in an article, the box's own height+depth in TeX pt:

body no amsmath (pdfTeX) amsmath (pdfTeX) before, either after
10pt 18.00017 18.00017 18.00017 ✓ 18.00017 ✓
11pt 18.00017 19.71019 19.71019 18.00017 / 19.71019 ✓
12pt 18.00017 21.60021 21.60021 18.00017 / 21.60021 ✓

A 12pt document without amsmath set \Big[ 6.00pt too tall; \bigg[ likewise (30.00029 where pdfTeX has 24.00022), and \Bigg[ ran one variant past the end of the fixed chain into an extensible recipe where pdfTeX uses the plain 30.00029 variant.

The kernel rule reproduces pdfTeX's height and depth separately, not just the sum — including the two cases where the \vbox floor is what decides the box: at 11pt \big[ is (8.50000+2.73750) because the chosen text [ is only 10.95pt tall and 8.5 is the floor, and at 12pt it is (9.00000+3.00000). tests/big_delimiters.rs pins all 24 boxes (4 commands × 3 body sizes × both rules) to 1e-4pt.

What changed

Nucleus::BigDelimiter carries a BigSizing naming which definition is in force instead of a bare factor. Atom::big_delimiter keeps its signature and its meaning (the amsmath rule), so every existing caller is unaffected; Atom::big_delimiter_kernel is the new one.

Nothing selects the kernel rule yet. Choosing between them is the caller's decision from the package list, and that caller is render-pipeline, which builds against vendor/math-layout. Per the brief I may not make vendor commits, so the pipeline half is a separate PR blocked on a re-pin of this commit — that is the math-layout/pipeline split, and it is the one thing here that is not done.

Gates

  • cargo test --release on crates/math-layout: 65 passed, 0 failed; control on this same base 61 passed, 0 failed (the 4 new ones are this file, failing set empty on both).
  • crates/render-pipeline is untouched and builds against its pinned vendor/math-layout, so the pipeline gates cannot move. Measured on this base through the CLI with FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRS at apps/mac/Fonts: HW1 3 pages / 0 errors / 6 warnings, HW2 3 pages / 0 errors / 9 warnings (identical to render-pipeline: paint vertical extensible delimiters from MathVariants assemblies #227's control), and all 8 fixtures/real-world entries keep their status, page count and error count.

Still wrong, measured here, not fixed

Each of these is a delimiter-height error I confirmed against \showbox and left alone; none is this PR's or #204's.

  • \left( is ~0.33% short at every size and package set — 23.92 vs pdfTeX 24.00023 at 10pt, 26.19240 vs 26.28026 at 11pt amsmath, 28.70400 vs 28.80028 at 12pt. [ and \{ are exact in the same runs, so it is specific to the paren chain.
  • \left|/\Bigg| never grow at all — 12.02pt against pdfTeX's 24.00024 / 30.00030 at 10pt, at every size. This looks like the U+2223-vs-U+2016 mapping render-pipeline: paint vertical extensible delimiters from MathVariants assemblies #227 flagged as out of scope, reaching the layout and not only the painting.
  • \sqrt produces no radical cluster at all under amsmath at 10/11/12pt, while it is exact (30.00029 vs 30.00000) without amsmath at 11/12pt. I did not chase whether that is a real gap or an artefact of matching the cluster by √.
  • The brief's "assert zero font diagnostics" does not hold on main with the font directories it specified: every corpus fixture reports math_resource_profile, and math-sheet additionally reports the 7 math_glyph_unmapped warnings that render-pipeline: paint vertical extensible delimiters from MathVariants assemblies #227 removes.

Draft: the kernel rule is inert until a reviewer takes the vendor re-pin, and the pipeline PR that selects it is not written.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…msmath

`make_big_delimiter` implemented only amsmath's `\bBigg@`: `\vcenter to
<factor>\big@size` with `\big@size` = 1.2 x the math strut. That is the
right rule *when amsmath is loaded*. The LaTeX kernel's own definition
(`fontmath.ltx` 513-520) is a different one, and it is what a document
without amsmath gets:

    \big  -> \left<d>\vbox to  8.5pt{}\right.
    \Big  -> \left<d>\vbox to 11.5pt{}\right.
    \bigg -> \left<d>\vbox to 14.5pt{}\right.
    \Bigg -> \left<d>\vbox to 17.5pt{}\right.

Two differences, not one. The lengths are absolute, so they do not follow
the body size; and the box is a `\vbox` (height `pt`, depth 0), not a
`\vcenter`, so Rule 19's delta is `max(pt - axis, axis)` rather than half
the target, and the result is floored at the vbox's own height.

The two rules coincide at 10pt and diverge everywhere else, which is why
this survived: every 10pt comparison agrees.

`\showbox` under pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025),
`\hbox{$\displaystyle\Big[$}` in an `article`, as the box's height+depth:

| body | no amsmath | amsmath | before (either) |
|---|---|---|---|
| 10pt | 18.00017 | 18.00017 | 18.00017 |
| 11pt | 18.00017 | 19.71019 | 19.71019 |
| 12pt | 18.00017 | 21.60021 | 21.60021 |

So a 12pt document without amsmath set `\Big[` 6.00pt too tall, and
`\bigg[`/`\Bigg[` one cmex variant too far up the chain as well.

`Nucleus::BigDelimiter` now carries a `BigSizing` naming which definition
is in force instead of a bare `factor`. `Atom::big_delimiter` keeps its
signature and its meaning (the amsmath rule); `Atom::big_delimiter_kernel`
is the new one. Nothing selects the kernel rule yet -- that is the caller's
decision from the package list, and it belongs to the pipeline, which
builds against `vendor/math-layout` and so needs a re-pin first.

Measured: `tests/big_delimiters.rs` pins all 24 pdfTeX boxes (4 commands x
3 body sizes x both rules) to 1e-4pt. `cargo test --release` on
`crates/math-layout`: 65 passed, 0 failed (control on this base: 61 passed,
0 failed; the 4 new ones are this file).

`crates/render-pipeline` is untouched and builds against its pinned
`vendor/math-layout`, so the pipeline gates cannot move: HW1 3 pages /
0 errors / 6 warnings and HW2 3 pages / 0 errors / 9 warnings, and all
8 `fixtures/real-world` entries keep their status, page count and error
count, measured through the CLI on this base.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer direct git (Cursor usage limit fallback)
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