Repository navigation
render-pipeline: math at the current text size, amsmath cmex designs, \dots/\bmod/\pmod spacing, one-letter \mathrm (needs #172 + #174 re-pin) - #177
Closed
GoKubar wants to merge 1 commit into
Conversation
…signs, \dots/\bmod/\pmod spacing, one-letter \mathrm
- TexMathMetrics::for_text_size builds on math-layout's
CmMathMetrics::for_text_size (\DeclareMathSizes + .fd designs, rm-lmr of
the same design); math_box takes the paragraph's text size and providers
are cached per size, so a \footnotesize note in an 11pt class sets 9/6/5pt
math (cmmi9/cmsy9) and body math is unchanged.
- Family 3 follows the packages: Computer Modern with amsmath/mathtools/
amsfonts/amssymb loads cmex7/8/9/10 at the math size (ExtensionSizing::
Designs, e.g. cmex10 at 10.95pt in HW1/HW2); lmodern and the kernel keep
sfixed cmex10. extension_box reads the design actually used.
- rewrite_math_spacing (source-driven, like fence_of/class_override_of):
\dots/\ldots/\cdots and amsmath \dotsc..\dotsi become \mathinner groups
of three \ldotp/\cdotp with amsmath's \dots context rules and trailing
\, or leading \!; \bmod 5mu each side, amsmath \mod 12/6mu, amsmath inline
\pmod 8mu. The compiler's text "..." left HW2 p3 5.52pt short.
- One-letter \mathrm (compiler Text at a \mathrm span) is math-layout's
TextChar, so K^{-1} places its exponent like pdfTeX.
- tests/math_font_sizes.rs: glyph origins vs pdflatex (size oracle) for
a,\dots,b, (1,\ldots,n), a\bmod b, f'(x), \mathrm{K}^{-1},
\epsilon+\varepsilon, and footnote math sizes.
Needs vendor/math-layout re-pinned to #172 and vendor/compiler to #174.
Implementation-Agent: Claude Opus 5 (subagent kabir-claude math font metrics, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 13, 2026
GoKubar
added a commit
that referenced
this pull request
Sep 13, 2026
…er microtype
Under `\usepackage{microtype}` pdfTeX expands the character nodes of an
inline formula with the rest of the line and lets a formula's first or last
character protrude into the margin. We handed the microtype line breaker one
opaque box per formula, so every glyph after the first formula on a line sat
up to 1.7pt away from pdflatex's.
`math_top_nodes` flattens math-layout's root into paragraph-layout's
`MathNode`s. It opens the atom hboxes that are siblings in TeX's list
(`[char, italic kern]`, `[nucleus, shifted script]`) and leaves every other
hbox a box, so scripts, fractions, `\sum`, `\sin` and `\left..\right` stay
unexpanded exactly as pdfTeX has them. `MathRec.shape` (`List`, `Kerned`,
`Opaque`) records where the top-level hlist lives; a formula holding a
top-level grid stays opaque. Top-level text-size roman characters get
`OT1/{cmr|lmr}/m/n` microtype parameters resolved from the roman TFM, which
is what microtype.cfg's `expansion=alltext-nott` selects. The painter then
moves the top-level nodes to the positions the packer chose.
New oracle `fixtures/microtype-math` (5 documents, 15 justified paragraphs,
`generate.py`; MacTeX pdfTeX 1.40.29) and `tests/microtype_math.rs`.
Measured on this machine against the committed expectations, same fonts and
metrics on both sides:
| fixture | main `1222354e` | with this commit |
|---|---|---|
| 01-digits-parens | 15/15 lines, **54** pen positions > 0.1pt, worst 1.678pt | 15/15, **0**, worst 0.026pt |
| 02-letters-relations | 15/15 lines, **38** > 0.1pt | 15/15, **0**, worst 0.066pt |
| 04-line-edges | **line breaks differ** | **17/17 lines**, 0 > 0.1pt, worst 0.049pt |
03 and 05 are `#[ignore]`d with their measured causes: `\sum` is 1.003pt
narrow (cmex10 at its 10pt design size, not the math size) and `\cdots`
5.475pt narrow (three `\cdotp`s, not `\mathinner`) — both PR #177; and the
compiler drops `\mathbb{Z}` and sets `\colon` literally — the compiler lane.
Neither is font expansion. Every other construct in those fixtures (`\frac`,
`\sqrt`, scripts, `+`, `=`, `\quad`, `\mid`, `\max`, `!`) is within 0.12pt.
Inline math's `\medmuskip`/`\thickmuskip` stretch and the Bin/Rel breakpoints
are `a2f85bfa`/`2c373747` on main, not this commit; this only adds expansion
and protrusion on top of them.
Gates (this machine; `apps/mac/Fonts` + a dereferenced TeX Live 2025 metric
tree whose four digest-bound TFMs are byte-identical to MacTeX's):
- render-pipeline `cargo test --release`: no suite differs from main except
`microtype_math` (main 0/5, here 3 passed + 2 ignored). `inline_math_breaks`
still 39/46 with no overfull line; `microtype_fixtures` 8/8.
- paragraph-layout `cargo test --release`: all green.
- compiler `cargo test --release`: 395 passed, 0 failed (same as main).
- amsmath corpus (`oracle.py check`): **59/59** within 0.5bp, same as main.
- Real-world corpus, all 10 fixtures with a reference PDF: line-for-line
identical to main, 0 overfull each. HW1 and HW2: 3 pages, 0 overfull,
identical to main. None of them loads microtype, so this is a no-change
gate, as intended.
Nothing under `vendor/` is committed; the gates above ran with an
uncommitted scratch copy of this branch's `crates/paragraph-layout` in
`vendor/paragraph-layout`, reverted afterwards. `vendor/paragraph-layout`
must be re-pinned to the commit before this one for the pipeline to build
standalone.
Implementation-Agent: claude-opus-5 (kabir-claude lane, linux-primary)
Commit-Executor: claude-opus-5 direct git (Cursor usage limit fallback)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
This was referenced Sep 15, 2026
Contributor
Author
|
Closing: the substance of this draft is on main. |
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.
Pipeline half of the math font metric fixes. Base
main. It builds only aftervendor/math-layoutis re-pinned to #172 andvendor/compilerto #174. Nothing undervendor/is committed. All gates below ran with an uncommitted scratch swap of both branches intovendor/, reverted afterwards.Changes
Math fonts follow the text size
TexMathMetrics::for_text_sizeuses math-layout'sCmMathMetrics::for_text_size: fontmath.ltx\DeclareMathSizesplus the.fddesigns, andrm-lmrof the same design.math_boxtakes the paragraph's text size, and providers are cached per size. Math in a\footnotesizenote of an 11pt class is set at 9/6/5pt with cmr9/cmmi9/cmsy9. Body math is unchanged.{\Large $x$}inside a paragraph still sets math at body size, becauseAItem::Mathcarries no text style (follow-up). render-pipeline: sectioning headings from class-geometry's \@startsection specs (oracle 38/41 exact) #151/render-pipeline: footnotes with floats, \thanks notes, footnote-size math (includes #140) #154 can replace their local size tables with this.Family 3 follows the packages
sfixedcmex10.extension_boxreads the design actually used.rewrite_math_spacing(reads the source, likefence_of/class_override_of)\dots,\ldots,\cdotsand\dotsc..\dotsibecome\mathinnergroups of three\ldotp/\cdotp(Inner viaclass_override_of). amsmath's\dotscontext rules apply (amsmath.sty 494-627):\dotsc,\dotsb,\dotso, the trailing\,before a right delimiter or$, and\dotsi's\!.\bmodgets 5mu on each side, amsmath\mod12/6mu, amsmath inline\pmod8mu. The kernel\pmodkeeps 18mu.One-letter
\mathrm\mathrm{K}becomes math-layout'sTextChar, soK^{-1}places its exponent like a character (siunitx compiler: siunitx v3 numbers, units, quantities, lists, ranges and angles #163/render-pipeline: siunitx pdflatex oracle (35/39; needs vendor/compiler re-pin from c93e58ca) #168).Tests
tests/math_font_sizes.rs, 7/7 pass. Glyph origins match pdfTeX (from the math-layout: math fonts at every LaTeX text size, amsmath cmex designs, \prime, \epsilon/\varepsilon (size oracle 37/37) #172 size oracle) within 0.3bp fora,\dots,b,(1,\ldots,n),a\bmod b,f'(x),\mathrm{K}^{-1}and\epsilon+\varepsilon, and footnote math sizes (9pt text, 6pt script) are checked.cargo test --release(render-pipeline, swapped vendor): all green, including footnotes, floats, tabular, page frame and golden.Gates (swapped vendor vs main
bffd168a)HW1/HW2 (#171's
measure.sh, MacTeX pdflatex oracle)3 pages each, 0 overfull, line breaks identical.
Words with dx > 0.1pt, main → this:
Fixed: HW2 p3
\ldots(−5.52pt), HW2 p2 line 467.2 (\varepsilonwidth), HW2 p3 polynomial ±1.82pt. No word got worse.amsmath corpus (
crates/compiler/tests/amsmath_corpus/oracle.py check): 59/59 before and after.Real-world corpus (
run.py --no-oracle --no-pixels): status and page counts unchanged for all 9 fixtures.input-bibliography: two
math_glyph_unmappederrors are gone.lecture-notes: one new$a = qb + r = q'b + r'$ …". Primes are now exact:
overfull_hbox(24.60pt) at "Uniqueness. Suppose$a = qb + r = q'b + r'$$(q - q')b = r' - r$pdflatex keeps the break after "and" because its inline math glue stretches. The pipeline's inline formula is a rigid box, so the narrower, correct line is no longer feasible. This is the known rigid-math limitation (math-layout: TeX stretch/shrink on math glue and hpack-exact pack_to (display-math blocker 1 of #146) #148/render-pipeline: squeeze too-wide displays, numbers on their own line, subequations label line (display-placement 33/36; needs #148 + #155 re-pin, includes #146) #157; the same effect is noted in render-pipeline: footnotes with floats, \thanks notes, footnote-size math (includes #140) #154), exposed rather than caused by this change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu