Repository navigation
render-pipeline: size family 3 as amsmath declares it, not sfixed*cmex10 - #204
Merged
Merged
Conversation
The LaTeX kernel loads the math extension family from `omxcmex.fd`'s
`<->sfixed*cmex10`, so family 3 is cmex10 at exactly 10pt in every style.
`TexMathMetrics::new` modelled only that, for every document.
amsfonts.sty 36-41 and amsmath.sty 109-114 redeclare `OMX/cmex/m/n` without
`sfixed`, so a document loading amsmath, amsfonts, amssymb, mathtools or
physics gets family 3 at the math size, in amsfonts' designs. Measured with
`\fontname\textfont3` under pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025):
packages 10pt 11pt 12pt
(none), amsthm, siunitx cmex10 cmex10 cmex10
amsmath / amsfonts / amssymb cmex10 cmex10 at 10.95pt cmex10 at 12.0pt
any of those + lmodern lmex10 lmex10 lmex10
[cmex10]{amsmath} cmex10 cmex10 cmex10
`\scriptfont3`/`\scriptscriptfont3` follow the same declaration (cmex7 and
cmex7 at 5pt at 10pt; cmex8 and cmex7 at 6pt at 11 and 12pt), which is why
even a 10pt document differs from `sfixed` inside scripts.
`lmodern` wins in either load order: it rebinds `largesymbols` to the `lmex`
family, which `omxlmex.fd` keeps `sfixed`, rather than the `cmex` shape
amsmath redeclares. That is why the amsmath and amssymb corpora — 12pt
documents that load lmodern — do not move.
math-layout already models this (`ExtensionSizing::Designs`, `cmex7/8/9`
embedded, PR #172); nothing selected it. `style::cmex_designs` decides from
the package list and amsmath's `cmex10` option, and `TexMathMetrics::new`
applies it.
Painting is corrected to match: `extension_box`, the `\widehat`/`\widetilde`
horizontal variant and the size-chain walk read the design the layout boxed
the glyph from instead of always CMEX10. The chains and extensible recipes
are identical across cmex7/8/9/10 (verified over all 128 slots), but the
accent widths are not — cmex7 "63 is 1.139 em against cmex10's 1.000 — and
neither is `\fontdimen8`, which sets a delimiter's height/depth split and so
the ink re-centring. `lm_name` no longer reports `lmex7/8/9`, fonts Latin
Modern does not ship.
Inline-math advance against pdflatex, `article` + amsmath,amssymb, measured
as the distance from the `A` before the formula to the `Z` after it, over 12
formulas x 3 class sizes: mean |error| 0.8415 bp -> 0.0004 bp, worst
2.1443 bp -> 0.0011 bp. The committed HW1/HW2 references (11pt, amsmath,
no lmodern) carry their cmex glyphs at 10.909 bp = 10.95pt; this pipeline
emitted them at 9.963 bp = 10pt and now emits 10.909 bp.
Gates: amsmath corpus 59/59, amssymb 38/39 (`32-braces-narrow` fails on main
too), math-layout and compiler suites all green, render-pipeline failing set
identical to a control build of the base commit under the same font
environment (8 pre-existing partial-font tests).
Implementation-Agent: Claude Opus 5 (engine-engineer, linux-primary NixOS)
Commit-Executor: Claude Opus 5 via Claude Code (Cursor quota unavailable)
Co-Authored-By: Claude Opus 5 <[email protected]>
Co-authored-by: GoKubar <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
marked this pull request as ready for review
September 13, 2026 23:36
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not merge — main is frozen for the v0.1.2 release run. Draft for review.
What was wrong
TexMathMetrics::newalways built itsCmMathMetricswithExtensionSizing::Fixed, modelling the LaTeX kernel'somxcmex.fd(
<->sfixed*cmex10): family 3 — every large operator, every\left…\rightfence, every
\big…\Bigg, the radical, and\fontdimen8, which sets thefraction rule thickness — pinned to cmex10 at exactly 10pt in every style and
at every body size.
amsfonts.sty36-41 andamsmath.sty109-114 redeclareOMX/cmex/m/nwithout
sfixed, so family 3 is loaded at the math size, in amsfonts'optical designs. Nothing in the pipeline noticed.
\fontname\textfont3under pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025),article:amsthm,siunitxcmex10cmex10cmex10amsmath/amsfonts/amssymb/mathtools/physicscmex10cmex10 at 10.95ptcmex10 at 12.0ptlmodern(either order)lmex10lmex10lmex10[cmex10]{amsmath}cmex10cmex10cmex10\scriptfont3/\scriptscriptfont3follow the same declaration —cmex7/cmex7 at 5.0ptat 10pt,cmex8/cmex7 at 6.0ptat 11 and 12pt— so even a 10pt document diverges from
sfixedinside scripts.lmodernwins in either load order because it rebinds the symbol font itself(
\DeclareSymbolFont{largesymbols}{OMX}{lmex}{m}{n}) rather than thecmexshape amsmath redeclares, and
omxlmex.fdkeepssfixed*lmex10.Why it mattered here
The amsmath/amssymb corpora are 12pt documents that also load
lmodern,so they were already correct and do not move — which is exactly why this hid.
HW1 and HW2 are
11pt+amsmath,amssymb,amsthmwith nolmodern. Theircommitted reference PDFs carry cmex glyphs at 10.909 bp = 10.95pt; this
pipeline emitted them at 9.963 bp = 10pt.
Running the project's own
reference-mactex2026.pdfregeneration against alocal pdflatex forced to
sfixed*cmex10(same binary both sides) isolates theerror on the real fixtures: 86 glyphs move on HW1 (worst 1.30 bp) and
56 on HW2 (worst 0.87 bp). Page count, overfull count and error count are
unchanged either way.
The fix
style::cmex_designs(packages, cmex10_option)decides from the package listand amsmath's
cmex10option;TexMathMetrics::newtakes it and appliesExtensionSizing::Designs. math-layout already modelled this —Designs,extension_design, and the embeddedcmex7/8/9all landed with #172 — butnothing selected it.
Painting is corrected to match, because the four cmex designs are not
scaled copies of one another:
extension_boxand the size-chain walk read the design the glyph was boxedfrom instead of always
CMEX10. Thenext_largerchains and extensiblerecipes are identical across cmex7/8/9/10 (verified over all 128 slots), so
the chain walk picks the same variant — but
\fontdimen8differs, whichsets a delimiter's height/depth split and therefore the ink re-centring.
\widehat/\widetildepick their horizontal variant from the realdesign. This is where the designs genuinely diverge: cmex7
"63is1.139 em against cmex10's 1.000, so the old code chose a variant up to 19%
too narrow at script sizes.
lm_nameno longer reportslmex7/lmex8/lmex9in the resourceprofile — fonts Latin Modern does not ship, and a document using those
designs has by definition not loaded
lmodern.Before / after against pdflatex
Inline-math advance,
article+amsmath,amssymb(no lmodern), measured asthe distance from the
Abefore the formula to theZafter it. pdflatex istruth; error in bp.
x_{\int a}x^{\sum a}a\int ba\sum b\left(\frac{\frac ab}{\frac cd}\right)\Biggl(x\Biggr)\sqrt{\frac ab}a\sum ba\prod b\sqrt{\frac ab}\Biggl(x\Biggr)x^{\sum a}Over the full grid of 12 formulas x 3 class sizes:
mean |error| 0.8415 bp → 0.0004 bp; worst 2.1443 bp → 0.0011 bp.
10pt text-style formulas were already exact and stay exact; the 10pt rows that
move are the script-size ones, as the font table predicts.
Gates
32-braces-narrowfails on main too)Committed oracle data was not regenerated.
Note on the brief
The assignment predicted HW1/HW2 would be untouched and that the 12pt amsmath
corpus would move. It is the other way round: the corpus loads
lmodernandwas already right, and HW1/HW2 are the 11pt no-
lmoderndocuments that werewrong. The measurements above are the evidence.
The companion side-fix the brief suggested — applying
tools/visual-oracle/fontenv.pyto the amsmath/amssymb
oracle.py— is already on main (#193,7715e8a1);both harnesses call
fontenv.render_envand honour the caller's fontenvironment. Nothing to do.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu