Repository navigation
math-layout: cmsy/cmmi/cmr/cmex slots and spacing classes for the LaTeX kernel math symbols - #186
Merged
Merged
Conversation
…x slot and class `cm::symbol_slot` and `mathlist::default_class` are the two tables that decide where a math character is set and how much glue surrounds it. Both were missing every kernel `\DeclareMathSymbol` outside the small set the pipeline had needed so far, so `\odot`, `\prec`, `\sqcup`, `\nearrow`, `\star`, `\dagger` and 41 more had no slot at all. Family and slot come from `fontmath.ltx` (TeX Live 2025), cited per row: `symbols` -> cmsy (`Family::Symbol`), `letters` -> cmmi (`Family::Italic`), `operators` -> cmr (`Family::Roman`), `largesymbols` -> cmex (`Family::Extension`). `\bigsqcup` (`"46`) and `\biguplus` (`"55`) are the two `largesymbols` `\mathop`s deferred from #180 because they needed exactly these rows. `\surd` is plain TeX's `{\mathchar"1270}` -- cmsy `"70`, braced, so Ord. Verified against pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025) at 10pt rather than assumed: `tests/kernel_symbols.rs` pins, for all 47, `\showthe\wd0` of `\hbox{$\sym$}` (the slot's TFM width -- a wrong family or slot moves it) and of `\hbox{$a\sym b$}` (that width plus the class's inter-atom glue: 0 for Ord, 2x3mu Op, 2x4mu Bin, 2x5mu Rel -- a wrong class moves it while the bare width stays right), read against the `$ab$` control of 9.57755pt. All 47 match to pdfTeX's own five decimals. `\imath`, `\jmath` and `\varrho`, already carried, are measured alongside as a control on the harness. `crates/math-layout` `cargo test --release`: 42 passed, 0 failed (was 38). `crates/compiler` (depends on this crate): 395 passed, 0 failed, unchanged. `crates/render-pipeline` builds against `vendor/math-layout`, so this commit does not move any rendered geometry until that pin is refreshed; the PR reports the measurement taken with the vendor swapped locally and uncommitted. Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary) Commit-Executor: claude-code (direct Git fallback, Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…lot carries Cross-checked the 31 `symbols`-family rows against the mapping this repo already states for family 2 -- `OMS_TEXT` in `crates/compiler/tests/amsmath_corpus/ oracle.py`. 29 of 31 agree; the two that did not were the ones I had taken from `unicode-math`'s command aliases. cmsy `"0D` is `◯` U+25EF, not U+25CB (Latin Modern Math sets U+25CB at 0.796 em where cmsy's slot is exactly 1 em), and cmsy `"0F` is `∙` U+2219, not WinAnsi's bullet U+2022. The measured widths in `tests/kernel_symbols.rs` do not move -- a slot's TFM width does not depend on which character keys it -- but the key must be the one the compiler emits, which the sibling PR corrects the same way. `crates/math-layout` `cargo test --release --no-fail-fast`: 42 passed, 0 failed. Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary) Commit-Executor: claude-code (direct Git fallback, Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…h's slots The sibling compiler PR emits `\imath`/`\jmath` as U+1D6A4/U+1D6A5, the Mathematical Alphanumeric dotless letters `unicode-math` names for them, rather than the text dotless pair U+0131/U+0237 the table already carried: in the bundled Latin Modern Math the math pair is 322/384 units, cmmi10's own 0.322456 em / 0.384030 em, where the text pair is 278/306. Both pairs now map to cmmi `"7B`/`"7C`, so the pipeline places either at pdfTeX's slot; the text pair keeps its row because a literal `ı` in prose is still a legitimate input. `tests/kernel_symbols.rs` measures all four against pdfTeX's `\showthe\wd0`; the widths are identical, as they must be -- a slot's TFM width does not depend on which character keys it. `crates/math-layout` `cargo test --release --no-fail-fast`: 42 passed, 0 failed. Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary) Commit-Executor: claude-code (direct Git fallback, Cursor usage limit) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
marked this pull request as ready for review
September 13, 2026 23:36
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
… CleverReference, default math-class-override (#477) The pin was 13 `crates/compiler` commits behind `main`, which left merged work inert in the pipeline. The one this was asked for is #474: `\paragraph` and `\subparagraph` are real compiler commands there, so `ps-calculus`'s four `\paragraph is not supported by this compiler version` errors are gone through the `render` producer. Nothing in the pipeline had to change for it -- the run-in head was already laid out by `adapter::run_in_heading_at`, which reads the command back from the source; the old pin's parser simply had no `"paragraph"` arm. Also now visible: #472 (mathtools colon relations), #473 (preamble `\setlength`/`\addtolength`), #455, #454, #456, #457, #460, #416, #424, #428, #444, #408. One new compiler API surfaced: `parser::Inline::CleverReference` (#460, cleveref). Three exhaustive matches in `adapter.rs` stopped building -- `inline_span`, the incremental paragraph-cache hash, and `items_from_inlines`. It is implemented, not dropped behind a wildcard: - `adapter::clever_reference_text` resolves `\cref`/`\Cref`/`\crefrange`/ `\cpageref`/`\labelcref` to text in `lower_inline`, exactly where `Reference` already was, so `items_from_inlines` keeps its `unreachable!` instead of gaining a swallow-everything arm. - `Labels` gains `kinds` (from `Inline::Label::kind`) and `cleveref` (from `Parsed::cleveref`) to feed it, and `Labels::needs_pages` now also answers true for a `\cpageref`, which otherwise had no page numbers to print. - The grouping, consecutive-number ranges, `and`/`, and` joining and parenthesised equation numbers mirror the compiler's private `layout::clever_reference_text`. The naming is *not* duplicated: `xref::cleveref_name`/`cleveref_kind` are public and are called, so `\crefname` and the `capitalise`/`noabbrev` options stay compiler-owned. - The one thing it cannot do is link. The compiler has no link backend, so `CleverReference::linked` is carried in the cache key and otherwise unused. `tests/cleveref.rs` was written against this and marked `#[ignore = "needs vendor re-pin past GH-CLEVEREF"]`. It is un-ignored and passes unchanged: `Section 2` and `eqs. (1) and (2)`. `math-class-override` becomes a default feature, as `amsmath-inline` and `par-leading` did once their preconditions were met: the re-pinned `math.rs` declares `pub class_override: Option<AtomClass>` and `pub enum AtomClass`. Without it #472 is merged but inert here, because `typeset::class_override_of` re-derives `\colon`'s class from source text that is identical with and without amsmath loaded. `class_override_of` stays as the no-default-features fallback. No other vendor directory had to move. `compiler`'s four path dependencies (`font-engine`, `tex-text-encoding`, `tex-boxes`, `tex-expansion`) are unchanged from the pin, and the three `tex-*` crates have had no commits at all since `87a513de`. `math-layout` *is* 8 commits behind `main` (#186, #229), but `compiler` does not depend on it, so that is a separate re-pin. The stale opening paragraph of VENDORING.md (which still named `ea4ee5c8` as the `compiler` pin and "~150 commits") is corrected. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed (364 baseline + the un-ignored cleveref test). - amsmath oracle corpus: `TOTAL 59/59 within 0.5 bp`. - `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf`, not by reading the harness summary -- 22/22 agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - The `packages::supersede_message` regression the last re-pin hit did not return: every `... are recognised but not implemented` line in the report is `render 0 / compiler N`, so none leak through the pipeline. Implementation-Agent: claude-opus-5 render-pipeline lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 render-pipeline lane, direct git (observed Cursor usage limit)
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
…ng skips, page-1 \@Texttop (#482) * render-pipeline: re-pin vendor/compiler faa7d48 -> 6a47ed4, implement CleverReference, default math-class-override The pin was 13 `crates/compiler` commits behind `main`, which left merged work inert in the pipeline. The one this was asked for is #474: `\paragraph` and `\subparagraph` are real compiler commands there, so `ps-calculus`'s four `\paragraph is not supported by this compiler version` errors are gone through the `render` producer. Nothing in the pipeline had to change for it -- the run-in head was already laid out by `adapter::run_in_heading_at`, which reads the command back from the source; the old pin's parser simply had no `"paragraph"` arm. Also now visible: #472 (mathtools colon relations), #473 (preamble `\setlength`/`\addtolength`), #455, #454, #456, #457, #460, #416, #424, #428, #444, #408. One new compiler API surfaced: `parser::Inline::CleverReference` (#460, cleveref). Three exhaustive matches in `adapter.rs` stopped building -- `inline_span`, the incremental paragraph-cache hash, and `items_from_inlines`. It is implemented, not dropped behind a wildcard: - `adapter::clever_reference_text` resolves `\cref`/`\Cref`/`\crefrange`/ `\cpageref`/`\labelcref` to text in `lower_inline`, exactly where `Reference` already was, so `items_from_inlines` keeps its `unreachable!` instead of gaining a swallow-everything arm. - `Labels` gains `kinds` (from `Inline::Label::kind`) and `cleveref` (from `Parsed::cleveref`) to feed it, and `Labels::needs_pages` now also answers true for a `\cpageref`, which otherwise had no page numbers to print. - The grouping, consecutive-number ranges, `and`/`, and` joining and parenthesised equation numbers mirror the compiler's private `layout::clever_reference_text`. The naming is *not* duplicated: `xref::cleveref_name`/`cleveref_kind` are public and are called, so `\crefname` and the `capitalise`/`noabbrev` options stay compiler-owned. - The one thing it cannot do is link. The compiler has no link backend, so `CleverReference::linked` is carried in the cache key and otherwise unused. `tests/cleveref.rs` was written against this and marked `#[ignore = "needs vendor re-pin past GH-CLEVEREF"]`. It is un-ignored and passes unchanged: `Section 2` and `eqs. (1) and (2)`. `math-class-override` becomes a default feature, as `amsmath-inline` and `par-leading` did once their preconditions were met: the re-pinned `math.rs` declares `pub class_override: Option<AtomClass>` and `pub enum AtomClass`. Without it #472 is merged but inert here, because `typeset::class_override_of` re-derives `\colon`'s class from source text that is identical with and without amsmath loaded. `class_override_of` stays as the no-default-features fallback. No other vendor directory had to move. `compiler`'s four path dependencies (`font-engine`, `tex-text-encoding`, `tex-boxes`, `tex-expansion`) are unchanged from the pin, and the three `tex-*` crates have had no commits at all since `87a513de`. `math-layout` *is* 8 commits behind `main` (#186, #229), but `compiler` does not depend on it, so that is a separate re-pin. The stale opening paragraph of VENDORING.md (which still named `ea4ee5c8` as the `compiler` pin and "~150 commits") is corrected. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed (364 baseline + the un-ignored cleveref test). - amsmath oracle corpus: `TOTAL 59/59 within 0.5 bp`. - `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf`, not by reading the harness summary -- 22/22 agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - The `packages::supersede_message` regression the last re-pin hit did not return: every `... are recognised but not implemented` line in the report is `render 0 / compiler N`, so none leak through the pipeline. Implementation-Agent: claude-opus-5 render-pipeline lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 render-pipeline lane, direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * render-pipeline: re-pin vendor/compiler onto #316 so the pipeline can see CBlock::LetterBlock Stacked on #477 (the re-pin to `main`). **Blocked on #316 merging**, and deliberately so: this is a temporary pin to an unmerged branch, the second such row in `vendor/VENDORING.md` after `vector-graphics`. Why a pin to a branch at all: PR #316 adds `parser::Block::LetterBlock`, and `adapter::inlines_of` matches `CBlock` exhaustively with no catch-all, so the render-pipeline side of the `letter` class is a hard compile error against any vendored compiler that lacks the variant. It cannot be written first and pinned later. `engine/letter-class-compiler` is `main` + one commit (`15264d7b`, rebased and green: 664 passed / 0 failed on `crates/compiler`), and `vendor/compiler` here is a plain `git archive` of its `crates/compiler`. **When #316 merges, re-pin this row to `main`** — `git archive <main>:crates/compiler` and nothing else. The compiler row of `VENDORING.md` says so in the first sentence. Two exhaustive matches in `adapter.rs` needed the new variant: `inlines_of` and the unit-building block walk. Neither gained a wildcard. `LetterBlock` carries `Vec<Vec<Inline>>` rather than one flat slice, so it is lowered in `lower_blocks` alongside `Verbatim`/`TitleBlock`/`VFill`: each line becomes an ordinary paragraph in the nearest alignment the pipeline has today (`flushright` for `\opening`'s return address, `flushleft` for the recipient and the closing), with **one typed `unsupported_block` limitation per block** naming exactly what is not applied — the `\longindentation` offset, the class's own vertical skips, and the `\raggedleft` box whose lines share a left edge where `flushright` aligns their right ones. No line of an `\opening` or a `\closing` is dropped, and nothing about the class is silently approximated. The typesetting PR stacked on this one replaces that arm and spends the skips the compiler already resolved. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: 365 passed / 0 failed. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf` — 22/22 agree. Zero font-FAILURE diagnostics. - `letter` compiles through the `render` producer with **0 errors**, where the #477 pin still reported seven `unknown_command`s (`\signature`, `\address`, `\opening`, `\closing`, `\encl`, `\cc`, `\ps`). Implementation-Agent: claude-opus-5 render-pipeline/letter lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * render-pipeline: typeset letter.cls — class \parskip, \opening/\closing skips, page-1 \@Texttop Stacked on the re-pin that gives the pipeline `CBlock::LetterBlock`, which in turn is stacked on #477 and blocked on #316. This is the third and last link of the `letter` chain: #297 gave the class its page frame, #316 gave the compiler the class's commands, and this makes the pipeline put the result where pdfLaTeX puts it. `fixtures/real-world/letter` was **218 words at 0% vertical accuracy**, the worst whole-fixture failure in the corpus. Landing the compiler alone did not move it: the class's commands parsed, and the page was still 93 bp out with **0 of 227 aligned words within 0.5 bp on the vertical axis**. Four separate things were wrong, and they had to be fixed in this order because each one hid the next. ## 1. `\parskip` is a class length, and the pipeline never read it `Stylesheet::from_resolved` copied `\parindent`, `\topskip` and `\maxdepth` out of `flashtex-class-geometry` but not `\parskip`, so every document kept `Stylesheet::article`'s `0pt plus 1pt`. For article/report/book that is identical to what the class says, which is why nobody noticed. letter.cls line 91 sets `0.7em` — 7.66498pt rigid at 11pt — so **every paragraph gap in every letter was 7.6 bp short**, and the error accumulated down the page. This is a no-op for every other class: `class-geometry`'s article `\parskip` is `Glue::new("0pt", "1pt", "0pt")` and `document-style`'s `PARSKIP` is `Skip::new(0.0, 1.0, 0.0)`. A document's own `\setlength\parskip` (#473) is applied later in `adapt_cached` and still wins. Effect alone: vertical agreement after removing a rigid page shift, 26.4% → 85.0%; max |dy| 186.5 → 67.6 bp. ## 2. `\opening`'s blocks are one paragraph each, not one paragraph per line The compiler hands over `lines: Vec<Vec<Inline>>` with the class's own skips already resolved into `gap_before_pt`, `gap_after_pt` and `extra_gap_after_pt` — all multiples of that `\parskip`. `lower_blocks` now spends them instead of dropping them, and joins each run of lines with `Inline::LineBreak` into **one** paragraph. That distinction is the whole structure: a `\\` inside a paragraph costs `\baselineskip`, a new paragraph costs `\baselineskip` *plus* `\parskip`, and letter.cls sets the address and the recipient as single `\\`-separated groups (a `tabular{l@{}}` and a `{\raggedright ...\par}`). The one mid-block gap, `\\*[2\parskip]` between `\fromaddress` and `\@date`, does split the paragraph, so the `\vspace` carrying it has the next paragraph's own `\parskip` taken out of it. Effect: max |dy| 67.6 → 41.9 bp — by then a *rigid* offset, the whole page uniformly too high. ## 3. `{\raggedleft ...}` is a declaration, not a `flushright` environment The recipient and the closing are now plain paragraphs rather than `Styled` ones. `letter.cls` writes them as `\raggedright` *declarations*, which carry none of `\trivlist`'s `\topsep`/`\partopsep` (9pt + 3pt at 11pt); a `Styled` block does, and it put both blocks 12pt too low. They are short, unwrapped lines, where `\raggedright` and justification set identical text, so this is the right vertical answer and the same horizontal one. The return address must stay right-aligned, so it stays `Styled(FlushRight)`, and the `env_close` pass — which gives any non-`Plain` paragraph `\@endparenv`'s `\@topsepadd` on the assumption that it came from an environment — now skips the paragraphs `lower_blocks` made from a letter block. They are keyed by their first inline's span, not the block's, because `\address`'s text comes from the **preamble** and lies outside `\opening`'s own span entirely. ## 4. letter.cls's page-1 `\@texttop` Line 405: \def\@Texttop{\ifnum\c@page=1\vskip \z@ plus.00006fil\relax\fi} On page 1 only, a fil glue sits at the top of the text block. Line 404's `\raggedbottom` — unguarded, unlike article's `\if@twoside\else\raggedbottom\fi`, so a `[twoside]` letter gets it too, which `Stylesheet::from_resolved` now also models — puts `\@textbottom`'s `\vskip \z@ \@plus.0001fil` at the bottom. The page's leftover space is shared in the ratio of their stretch, so the top takes 3/8 of it and the first baseline moves down by that much. `crates/class-geometry`'s `letter_oracle` documents this exactly and is why it checks its frame model on page 2 and only bounds page 1: the shift is page building, not a frame length, so it belongs here. Without it every letter's page 1 rode 41.95 bp too high on this fixture — a rigid offset that held *0%* of the page's words outside 0.5 bp however exactly the spacing between them was set. Effect: max |dy| 41.9 → 4.3 bp. ## Where `letter` now is | | dx ≤ 0.5 bp | dy ≤ 0.5 bp | dy ≤ 0.5 after a rigid shift | max \|dy\| | |---|---|---|---|---| | before #316 | — | — | — | the page had no letter structure at all | | #316 + re-pin only | 93.39% | **0.00%** | 26.43% | 186.46 bp | | this PR | 93.39% | 3.96% | **89.43%** | **4.29 bp** | Measured with `tools/visual-oracle/rank.py` against the pinned `fixtures/real-world/letter/reference.pdf`. Line by line the address block is within 0.39 bp, the whole body (17 of the 26 lines) within 1.37 bp, and nothing is worse than 4.29 bp. ## What is still wrong, measured rather than hidden Three residuals, each diagnosed and none of them silent: * **2.92 bp** at the boundary into `\closing`. Its argument goes in a `\parbox` whose first line is a `\strut` and whose height drives the interline glue TeX chooses; the pipeline has no `\parbox` box model to hang that on. * **0.98 bp** at the boundary out of `\opening`'s return address, which pdfLaTeX sets in a `tabular` whose last row carries `\@arstrut`'s `0.3\baselineskip` depth where a text line carries its glyphs'. * Those two make our content 2.91 bp taller than the reference's between the first and last baseline, which feeds back through the `\@texttop` share above and leaves the whole page a uniform ~1.4 bp low. That is why `dy ≤ 0.5` is 3.96% and not ~100%: the structure is right and the total height is not. Fix either box model and the axis should snap. Horizontally, the one remaining item is `\longindentation`: the closing and signature sit at the left margin instead of 180pt in (max |dx| 179.328 bp is exactly that length). `Block::Paragraph` has no per-paragraph left offset or measure, so it cannot be expressed yet; it keeps its typed `unsupported_block` limitation naming the exact offset, as does the `\raggedleft` box whose lines share a *left* edge where `flushright` aligns their right ones. One more difference this PR does not fix and the new test records: this page carries a folio and the reference does not, because `\opening` runs `\thispagestyle{empty}` whenever `\fromaddress` is non-empty (letter.cls 170-176). That is a page-style event the compiler does not emit yet. `crates/render-pipeline/tests/letter_class_geometry.rs` pins all four fixes against the reference's own baselines, with a per-boundary tolerance that is the measured residual rather than a margin chosen to pass — tightening those numbers is the next lane's gate. Verified with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to the bundled `apps/mac/Fonts`: - `cargo test --release --no-fail-fast -p flashtex-render-pipeline`: **370 passed / 0 failed** (365 + the 5 new letter tests). - amsmath oracle corpus `TOTAL 59/59 within 0.5 bp`; `tabular_oracle: 106/106 fixtures match pdflatex`. - Real-world corpus, all 22 fixtures: page counts checked by counting `/Type /Page` leaf objects in each `reference.pdf` and in each produced `render.pdf` — **22/22** agree. Zero font-FAILURE diagnostics on either producer. HW1 and HW2: 3 pages, 0 errors. - Full `tools/visual-oracle/rank.py` sweep of the corpus in `docs/evidence/visual-oracle-letter-after/`: no fixture regressed, and the 21 non-letter fixtures are untouched by construction — the `\parskip` read is a no-op for their classes and the other two changes are gated on `ClassKind::Letter`. Implementation-Agent: claude-opus-5 render-pipeline/letter lane (agent-a98bd88c4a9d49a22) Commit-Executor: claude-opus-5 direct git (observed Cursor usage limit) Co-authored-by: GoKubar <[email protected]> * vendor: re-pin compiler to main c95977d (now that #316's letter class has landed)
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.
Layout half of the LaTeX kernel math-symbol gap #180's sweep found. Compiler half is #185 (
agent/kabir-claude/math-kernel-symbols-compiler). Both are based onmain89e49fedindependently — no stacking, no overlapping files, either can merge first. Neither touches #180's or #181's branches.What changed
cm::symbol_slotandmathlist::default_classare the two tables that decide where a math character is set (family + TFM slot) and how much glue surrounds it (atom class). Between them they carried none of the LaTeX kernel\DeclareMathSymbols outside the small set the pipeline had needed so far, so\odot,\prec,\sqcup,\nearrow,\star,\daggerand 41 more had no slot at all — the pipeline could not place them even once the compiler emitted them.46 characters new to
symbol_slot, family and slot fromfontmath.ltx(TeX Live 2025) and cited per row (48 rows in all: the other two are the Mathematical Alphanumeric keys for\imath/\jmath, below), plus 35default_classentries (16 Bin, 17 Rel, 2 Op):fontmath.ltxfamilycm::FamilysymbolsSymbollettersItalicoperatorsRomanlargesymbolsExtension\bigsqcup(cmex"46) and\biguplus("55) are the twolargesymbols\mathops #180 deferred precisely because they needed these rows; both getLimits::DisplayLimitsand a realnext_largerdisplay variant, like\sum.\surdis plain TeX's{\mathchar"1270}— cmsy"70, class 1, but braced, so the atom is Ord, which the measurement confirms.Measured against pdfTeX, not assumed
tests/kernel_symbols.rspins two\showthe\wd0numbers per symbol from pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025) at 10pt:\hbox{$\sym$}— the TFM width of the slot the family row names. A wrong family or a wrong slot moves it.\hbox{$a\sym b$}— that width plus the inter-atom glue the class decides (0 for Ord, 2×3mu Op, 2×4mu Bin, 2×5mu Rel), read against the$ab$control of 9.57755pt. A wrong class moves it while the bare width stays right.The table measures 51 (command, character) pairs covering 49 commands, and all of them match to pdfTeX's own five decimals, first run. Three of the 49 —
\imath,\jmathand\varrho— were already carried bysymbol_slot; they are measured alongside as a control on the harness itself,\imath/\jmathat both their old and new code points.Two code points corrected against the repo's own table
The character each row is keyed by is the code point the cmsy/cmmi slot carries, which is what
crates/compiler/tests/amsmath_corpus/oracle.py'sOMS_TEXTalready states for family 2 (it exists so the oracle can name reference glyphs and align words). 29 of the 31symbolsrows agreed with it; the two that did not were the ones I had taken fromunicode-math's command aliases, andOMS_TEXTis right in both:"0D\bigcircis◯U+25EF — 1013 units in the bundled Latin Modern Math, matching cmsy's exactly-1 em slot — not U+25CB (796)."0F\bulletis∙U+2219, not WinAnsi's bullet U+2022.Slot widths do not depend on which character keys them, so the measured table did not move — but the key must be the one the compiler emits, and #185 corrects it the same way.
\imath/\jmathlikewise gained U+1D6A4/U+1D6A5 (unicode-math's Mathematical Alphanumeric dotless letters, 322/384 units = cmmi10's own 0.322456 em / 0.384030 em) alongside the text dotless pair U+0131/U+0237, which keeps its row because a literalıin prose is still legitimate input.Gates
crates/render-pipelinebuilds againstvendor/math-layout, so this commit moves no rendered geometry until that pin is refreshed. The end-to-end numbers below were taken withvendor/math-layoutandvendor/compilerlocally swapped to this branch and #185 (uncommitted, as the vendoring rules require); no vendor file is committed here (git diff origin/main -- crates/render-pipeline/vendor/is empty).Font setup: a symlink-free flat directory of the repo's own
apps/mac/Fonts/*.otfplus every.tfmunderapps/mac/Fonts/texmf, and a real copy of thattexmftree next to the binary — the rooted required-metrics reader only looks at<exe>/../Resources/texmf,<exe>/texmfand<exe>/../share/flashtex/texmf, never atFLASHTEX_TFM_DIRS. Without it every run reportsrequired_metrics_unavailable, falls back to OpenType MATH metrics, and both corpora score 0/59 and 0/39 on unmodifiedmain. Every number below was taken only after asserting zerofont_unavailable/required_metrics_unavailable/ec_metrics_unavailable.crates/math-layoutcargo test --release --no-fail-fastcrates/compiler(depends on this crate)crates/render-pipelinecargo test --release --no-fail-fastFLASHTEX_*exports)32-braces-narrow)--no-oracle)flashtex-render --tex)End-to-end. A 12pt fixture holding
$a\sym b$for all 50 of the pair's symbols with ASCII text anchors between them, measured against TeX Live 2025pdflatexwith the repo's own oracle machinery (pdftext.py,oracle.ref_pages/cand_pages):not supporteddiagnosticsmain)Anchors, not the math words:
pdftexthas no glyph-name table for cmmi/OMI, so this PR's 12letters-family symbols (the harpoons,\star,\triangleleft/\triangleright,\flat/\natural/\sharp,\smile/\frown) read as?on the reference side and cannot be paired by text. Each anchor's x is the cumulative width of every formula before it, so a wrong slot or class still moves it — which is what the 236.853 bp control shows.Follow-up this PR does not take
An
OMI_TEXTtable for cmmi, alongside the oracle's existingOMS_TEXT, would let the amsmath/amssymb harnesses pairletters-family math words by text instead of dropping them to?. That would turn the anchor measurement above into a direct per-glyph one. It belongs with the oracle tooling, not here.Resume notes
agent/kabir-claude/math-kernel-symbols-layout, headc1702353, based onmain89e49fed. Three commits.6fb5cb03.crates/math-layout/src/{cm,mathlist}.rs,crates/math-layout/tests/kernel_symbols.rs. Nothing else.vendor/math-layoutre-pin:crates/math-layoutcargo test --test kernel_symbols(4 tests, 51 command/character pairs × 2 pdfTeX widths each), then the end-to-end table above withvendor/compileron compiler: 50 LaTeX kernel math symbols (\odot, \prec, \sqcup, \bigsqcup, the suits, harpoons and diagonal arrows) #185.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu