Repository navigation
Conversation
…amsmath's definition when amsmath is loaded
`math::parse_tokens` took no package context, so every construct a
package redefines silently got the LaTeX kernel's definition -- the
wrong one whenever the document actually loaded the package. `\colon`
is the case that forced this: the kernel declares it punctuation
(`fontmath.ltx` 400, `\DeclareMathSymbol{\colon}{\mathpunct}{operators}
{"3A}`, 0mu/3mu) and amsmath renews it (`amsmath.sty` 409-410) to
`\nobreak\mskip2mu\mathpunct{}\nonscript\mkern-\thinmuskip{:}\mskip6mu
plus1mu\relax`, whose empty punctuation atom's 3mu is cancelled by the
negative kern behind it -- leaving an *ordinary* `:` with 2mu before
and 6mu after. Most documents that write `\colon` load amsmath.
Measured with TeX Live 2025 pdflatex at 10pt, control `\hbox{$ab$}` =
9.57755pt:
| box | no amsmath | with amsmath | delta |
| --- | ---: | ---: | ---: |
| `\hbox{$\colon$}` | 2.77779pt | 7.22212pt | +8mu |
| `\hbox{$a\colon b$}` | 14.02196pt | 16.79967pt | +5mu |
| `\hbox{$a\colon=b$}` | 24.57747pt | 30.13289pt | +10mu |
| `\hbox{$a\colon+b$}` | 21.79976pt | 29.0218pt | +13mu |
| `\hbox{$f\colon A\to B$}` | 41.55893pt | 44.33664pt | +5mu |
The 10mu and 13mu rows are the class in evidence, not just the glue:
the kernel's punctuation atom turns a following `+` into an Ord
(TeXbook Chapter 17's Bin-after-Punct rule) where amsmath's ordinary
one leaves it a Bin. The three-atom model this emits -- `space(2/18)`,
a `:` forced Ord, `space(6/18)` -- was checked against amsmath's own
expansion inside one document and is identical to the scaled point in
text, display, script and scriptscript style, and for `\colon` at a
formula boundary, before a relation, before a binary, and doubled.
## The mechanism
`MathPackages` is a `Copy` value carried by `MathParser` and passed to
`parse_tokens` / `parse_tokens_reporting_unclosed` as a required
parameter, so a caller cannot forget it and silently fall back to the
kernel. `parser::P` folds it from `\documentclass` and each
`\usepackage` name into a `math_packages` field -- the shape
`P::colors` and `P::font_encoding` already use, and the one that can
capture package *options* later, since the parser reads and drops them
in the same place. It is deliberately not a global: siunitx's
thread-local `Settings` is the mistake this does not repeat, and one
process compiles many documents. `siunitx::typeset`/`Context` take it
too, because `Context::math` re-parses synthesized unit formulas and is
the one path into the math parser with no document in scope.
Which packages and classes carry amsmath's definitions in was measured,
not assumed: each name was compiled with pdflatex and
`\hbox{$a a\colon b b$}` compared against the kernel expansion
(23.5995pt) and the amsmath expansion (26.37721pt) in the same
document, so font metrics cancel. Loading amsmath: `mathtools`,
`empheq`, `physics`, `nccmath`, `aligned-overset`, `cool`, `commath`,
`mismath`, `mhchem`, `chemformula`, and the `amsart`/`amsbook`/
`amsproc`/`acmart`/`beamer` classes. Measured as leaving the kernel's
alone, and so deliberately absent: `amsthm`, `amssymb`, `amsfonts`,
`amsopn`, `amsbsy`, `amscd`, `amstext`, `bm`, `unicode-math`,
`siunitx`, `esint`, `breqn`, `cases`, `mathdots`, `thmtools`, `braket`,
`cancel`, `tikz-cd`, `diagbox`, and the `article`/`report`/`book`/
`memoir`/`scrartcl`/`scrbook`/`scrreprt`/`revtex4-2`/`elsarticle`/
`IEEEtran`/`letter`/`proc`/`slides`/`amsdtx` classes.
`\colon` was previously diagnosed `\colon is not supported in math
mode` and typeset literally, so both definitions are new behaviour; it
joins the supported-LaTeX inventory and the generated artefacts are
regenerated.
`math::AtomClass` and `MathAtom::class_override` become public. The
render pipeline re-derives the forced class today by reading the
control word back out of the source at the atom's span
(`typeset::class_override_of`), which cannot tell `\colon`'s two
definitions apart -- they are the same five characters of source. The
sibling pipeline PR reads the field instead, behind its own feature.
## Gates
`cargo test --release` in `crates/compiler`: 444 passed, 0 failed,
against 441 passed / 0 failed at the same base (590fd86) in a separate
control worktree -- the 3 new tests, no other change. (`--test
robustness`'s `deeply_nested_input_does_not_blow_the_stack` overflows
in a *debug* build on this machine identically on both sides; release
passes on both.)
Real-world corpus (`tools/real-world-corpus/run.py --no-oracle`, this
checkout's binaries): 20 fixture/producer pairs, status, page counts
and exact diagnostic message sets identical to the control. hw1 and hw2
render 3 pages each, 0 errors, 0 overfull.
`crates/render-pipeline` vendors its own pinned copy of this crate
(`flashtex-compiler = { path = "vendor/compiler" }`), so nothing here
reaches `flashtex-render` until that pin moves; the render gates were
therefore also run through an *uncommitted* vendor swap, together with
the sibling pipeline change. amsmath corpus 59/59, amssymb 38/39
(`32-braces-narrow`, 1.012 bp, fails at this base too), both with zero
font diagnostics. Through that full stack `\hbox{$X a\colon b X$}`
renders within 0.0001 bp of pdflatex with and without amsmath.
Implementation-Agent: Claude Code engine-engineer (linux-primary, NixOS)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…th-package-context
`apps/mac/scripts/sync-supported-latex.sh --check` and `CompletionTests.testBundledInventoryMatchesTheCompiler` compare `apps/mac/Sources/FlashTeXMac/Resources/supported-latex.json` against `crates/compiler/supported/supported-latex.json` by sha256, so the editor's completion vocabulary never drifts from the compiler. The two were byte-identical at this branch's base (21eed5701677) and the previous commit regenerated the compiler-side copy, so the bundled one had to follow. Regenerated with the script, not by hand; the check now reports `bundled copy is current (23d25a1ff459)`. Implementation-Agent: Claude Code engine-engineer (linux-primary, NixOS) Commit-Executor: git via Claude Code Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…context' into agent/kabir-claude/math-package-gating # Conflicts: # docs/user/compiler.md
`math::command_atom` applied the amssymb/amsfonts table unconditionally, so
`\square`, `\nleq`, `\mho` and the other 218 commands it answers rendered
happily in documents that never loaded the package. Probed with `\ifcsname`
under TeX Live 2025, base LaTeX2e has **no definition for any of them** and
pdflatex answers "Undefined control sequence", so this was a 1:1 divergence
across the whole table, not a few symbols.
Each symbol now carries the file that declares it (`amssymb::Provider`,
generated, not hand-written: `gen_amssymb.py` collects the declarations from
both `.sty` files before the dedup that used to hide `amsfonts.sty` 141-147's
re-declaration of `\square`, `\lozenge`, `\rightsquigarrow`,
`\vartriangleright`, `\vartriangleleft`, `\trianglerighteq` and
`\trianglelefteq`). `MathPackages` gains `amssymb` and `amsfonts` flags beside
`amsmath`, and `command_atom` diagnoses the missing `\usepackage` instead of
rendering. The regenerated table is byte-identical to the committed one apart
from the new field.
The same gate covers the four commands with their own arms rather than a table
row — `\varnothing`, the dashed arrows, `\mathbb`/`\mathfrak` and the obsolete
`\Bbb`/`\bold` (`\mathbf`, which `\bold` stands for, is the kernel's and stays
unconditional).
Negative behaviour, measured rather than assumed:
* `\angle` and `\hbar` are the two commands here base LaTeX2e *does* define,
as composites amsfonts replaces. Without the package they keep the kernel
advance: `\hbox{$\angle$}` 6.37344pt against amssymb's 7.22223pt, and
`\hbox{$\hbar$}` 5.76172pt against 5.40280pt. The `\hbar` composite
reproduces exactly from its pieces (macron 5.00002 + `\mkern-9mu` -4.99988 +
math italic h 5.76158). Neither changes atom class.
* Everything else in the table is diagnosed, because pdflatex errors.
Which package loads which was measured, not assumed: every candidate compiled
with pdflatex and probed for `\nleq` (amssymb only), `\ulcorner` (also
amsfonts) and `\binom` (amsmath). `txfonts`, `pxfonts`, `newtxmath`,
`newpxmath`, `mathabx`, `kpfonts`, `MnSymbol` and `cool` really do load
amssymb; `amsart`/`amsbook`/`amsproc` load amsfonts but not amssymb;
`acmart`/`beamer` load both. `libertinust1math`, `fourier` and `siunitx`
define part of the inventory themselves without either AMS package and are
deliberately absent.
Tier 1 of #198's audit, each measured before and after against pdflatex:
* `\pmod` inline opens with amsmath's `\mkern8mu`, not the kernel's 18mu:
`$a\pmod{y}$` 50.82503pt -> 45.26960pt, matching `$a\mkern8mu(...)$`
exactly. Display is 18mu under both (`\@displaytrue` puts amsmath back on
50.82503), so display formulas are untouched.
* `\bmod` is 5mu on each side, not the 4mu of its Bin class, under every
package: `$a\bmod b$` 34.29970 against an ordinary `mod` at 28.74428, and
`$\bmod b$` 24.56947 against 23.45839 where the Bin degrades to Ord.
* Text-mode `\,`/`\!` take amsmath's `.1667em` when amsmath is loaded: 20sp
wider at 10pt, 24sp at 12pt. `\:`/`\;` are identical under both, and the
math-mode `\mskip` forms do not move.
The inventory now records which package each symbol needs, so
`supported-latex.json` and the Mac bundled copy say "needs amssymb" where they
used to claim an unconditional symbol.
Gates, `crates/compiler` `cargo test --release`: **457 passed, 0 failed**
against **448 passed, 0 failed** at the base (62200c0 + #198) in the same
worktree; the +9 are this change's tests. Through an uncommitted full vendor
swap into `crates/render-pipeline`, the amsmath corpus is 59/59 and the
amssymb corpus 38/39 (`32-braces-narrow`, 1.012 bp, fails at the base too) —
**byte-identical output files** to the same swap of the base, with zero font
diagnostics. Every real-world fixture compiles with no new diagnostic: they
all load their packages, including through the `\usepackage{amsmath,amssymb}`
comma form.
Stacked on #198, whose `MathPackages` this extends; the merge of that branch
is the first parent commit here.
Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary worktree
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
…th-package-gating # Conflicts: # docs/user/compiler.md
…smath-construct-gating
`math::command_atom` applied the amsmath bundle's 37 math constructs
unconditionally. Nothing checked that the document wrote
`\usepackage{amsmath}`, so `\text`, `\binom`, `\boxed`, `\dfrac`,
`\operatorname`, `\tag`, `\mod` and 30 more rendered happily in a document
that loaded no package at all, where pdflatex answers
`! Undefined control sequence`.
Measured, not assumed: every supported math command was probed with
`\ifcsname` under TeX Live 2025 pdflatex with an empty preamble and then
under amsmath, amstext, amsopn, amsbsy, amsfonts, amssymb and mathtools.
Of 542 commands, base LaTeX2e defines 261, 225 are the amssymb/amsfonts
table `MathPackages::provides` already gates, **37 are these**, and 19
belong to packages outside the AMS bundle.
The four bundle files are distinguished, because a document can load one
without amsmath: `\usepackage{siunitx}` gives `\text` alone and
`\usepackage{bm}` gives `\boldsymbol` alone, so the diagnostic names the
`\usepackage` that actually fixes the document.
The gate sits before the dispatch, so it covers the table rows and the
dedicated parser arms alike -- most of these 37 have their own arm, several
shared with a kernel command that must stay unconditional (`\dots` beside
`\dotsc`, `\stackrel` beside `\overset`, `\overline` beside `\boxed`).
`\lvert`/`\rvert`/`\lVert`/`\rVert` reach a fence through `take_delimiter`
rather than `command_atom`, so that path is gated too.
Eleven packages measured as loading amsmath transitively were missing from
`AMSMATH_PACKAGES`: breqn, newtxmath, newpxmath, kpfonts, MnSymbol,
libertinust1math, newtx, nicematrix, extarrows, yhmath -- each confirmed
with `\@ifpackageloaded{amsmath}`, the authoritative question, which
`\ifcsname binom\endcsname` alone cannot answer (nath defines `\binom`
itself and loads no AMS file, and stays deliberately absent).
`\mod` is no longer left as it was. amsmath.sty 910-911 makes it
`\allowbreak\if@display\mkern18mu\else\mkern12mu\fi{\operator@font mod}\,\,#1`
-- an opening kern, an *ordinary* upright mod (a group, not `\mathbin` like
`\bmod`), 6mu, and one argument it did not take before. Measured at 10pt:
`$x\mod{y}$` 40.14336pt, identical to
`$x\mkern12mu\mathrm{mod}\mkern6mu y$`.
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
Co-authored-by: GoKubar <[email protected]>
This was referenced Sep 14, 2026
This was referenced Sep 15, 2026
Contributor
|
Superseded — landed via Verified on Residual tracked, not lost: the Closed by the Commander after a stale-draft screening pass that required evidence in both directions — a landing SHA to close, an empty grep to keep open. If this verdict is wrong, say so on issue #2 and I will reopen: an asymmetric bar has produced wrong calls here in both directions before. |
3 tasks done
ItsAkilesh
pushed a commit
to ItsAkilesh/flashtex
that referenced
this pull request
Sep 18, 2026
…tex#769) Split out from PR flash-tex#247 (closed as superseded); the fix itself never landed when flash-tex#247 was superseded by flash-tex#230/flash-tex#529/flash-tex#530. main still carried \mod as an unconditional plain text atom, with a comment saying the gap was deliberate. - \mod is undefined in base LaTeX2e (amsmath.sty 910-911); gated the same way \sideset already is: `"mod" if !self.packages.amsmath => self.missing_package(...)`. - Under amsmath, \mod opens with \mkern12mu (inline; this compiler has no display flag, so the inline number is the one that applies, matching how \pmod already handles the same distinction), sets its argument as an ordinary (not Bin) upright "mod" via required_group + class_override, and puts 6mu before the argument. Two new constants, AMSMATH_MOD_OPENING_MU and AMSMATH_MOD_TRAILING_MU, mirror the existing AMSMATH_POD_MU/BMOD_EXTRA_MU pattern. Verified against TeX Live 2025 pdflatex at 10pt (see the code comment for the measured equivalences); added mod_needs_amsmath (mirrors sideset_needs_amsmath) and a width test mirroring the existing pmod/bmod style. cargo test --lib: 414 passed, 0 failed. Commit-Executor: daniel-muse-lead (Claude Sonnet)
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.
Follow-up lane to #230, which measured these 37 and deliberately left them. Stacked on #230, whose
MathPackages, generated provider field and diagnose-instead-of-render fallback this reuses; that branch is merged in as this branch's second parent, so the diff below contains #230's commits as well as this one. Review6d93d5c7.The problem
math::command_atomapplied the amsmath bundle's math constructs unconditionally. Nothing checked that the document wrote\usepackage{amsmath}, so\text,\binom,\boxed,\dfrac,\operatorname,\tag,\modand 30 more rendered happily in a document that loaded no package at all, where pdflatex answers! Undefined control sequence.Wider blast radius than the symbol table #230 gated:
\squareand\nleqbelong to documents that were going to load amssymb anyway, but\textand\dfracappear in ordinary ones.The measured list
I did not trust the 37. Every supported math command was probed with
\ifcsnameunder TeX Live 2025 pdflatex with an empty preamble and then underamsmath,amstext,amsopn,amsbsy,amsfonts,amssymbandmathtools— the same method as #230:The 37 agree exactly with #230's count, and the probe splits them by declaring file, which matters because a document can load one without amsmath:
amstext.sty—\textamsopn.sty—\operatorname,\operatornamewithlimitsamsbsy.sty—\boldsymbolamsmath.sty(33) —\binom\boxed\cfrac\dbinom\dfrac\dotsb\dotsc\dotsi\dotsm\dotso\genfrac\iiint\iint\impliedby\implies\lVert\lvert\mod\notag\overleftrightarrow\overset\rVert\rvert\substack\tag\tbinom\tfrac\underleftarrow\underleftrightarrow\underrightarrow\underset\xleftarrow\xrightarrowamsmath.styline 78 is\RequirePackage{amstext,amsbsy,amsopn}, so\usepackage{amsmath}sets all four flags;\usepackage{siunitx}sets onlyamstextand\usepackage{bm}onlyamsbsy, both measured. The diagnostic names the\usepackagethat actually fixes the document:\text requires \usepackage{amstext}.The gate
One check before the dispatch, so it covers the table rows and the dedicated parser arms alike. That placement is the point: most of the 37 have their own
command_atomarm, and several share that arm with a kernel command that must stay unconditional —\dots/\ldots/\cdotsbeside\dotsc,\stackrelbeside\overset,\overline/\underline/\overbrace/\overrightarrowbeside\boxed,\iffbeside\implies,\nonumberbeside\notag,\fracbeside\dfrac,\mathbfbeside\boldsymbol,\bmod/\pmodbeside\mod. Gating at the arm would have had to split every one of them by hand; gating by name does not. A test locks all of those kernel neighbours as still rendering with nothing loaded.\lvert,\rvert,\lVertand\rVertare the exception that needed a second site: they reach a fence throughtake_delimiter, notcommand_atom, so\left\lvert x\right\rvertwalked straight past. Both paths are gated;\vert,\Vert,\lbrace,\langle,\lfloorand\lceilin the same list are the kernel's and stay unconditional.Recovery is #230's: diagnose, then the same literal fallback every unsupported math command already uses.
The loader set — and a correction to #198's
Measured with
\@ifpackageloaded, not only\ifcsname. That is the authoritative question, and the two disagree:\ifcsname binom\endcsnamecannot tell "loads amsmath" from "defines\binomitself".Eleven packages were missing from
AMSMATH_PACKAGES, each confirmed as\@ifpackageloaded{amsmath}= yes with all four of\binom/\text/\operatorname/\boldsymboldefined:breqn,newtxmath,newpxmath,kpfonts,MnSymbol,libertinust1math,newtx,nicematrix,extarrows,yhmath. Classes were already right (amsart,amsbook,amsproc,acmart,beamer);article,report,book,memoir,scrartcl,elsarticle,IEEEtran,llncs,achemso,tufte-*,standalone,examload nothing.Two of those eleven are corrections worth stating plainly:
breqnwas on the "does not load amsmath" list and that is wrong.\@ifpackageloaded{amsmath}is yes under it. What compiler: thread the loaded packages into math parsing; \colon takes amsmath's definition when amsmath is loaded #198's\colon-width probe actually saw is that breqn replaces\colonagain throughflexisymafter loading amsmath:\hbox{$a a\colon b b$}is the kernel's 23.5995pt under breqn, while\pmod(45.2696pt) and\mod(40.14336pt) are amsmath's. One flag cannot say both. The flag means "amsmath.sty is loaded", so breqn now sets it and\colonunder breqn takes amsmath's width — a stated residual, and the narrower of the two errors: a breqn document is far more likely to write\binomthan\colon, and everything else about it diverges further than 2.8pt already.libertinust1mathstays deliberately absent fromAMSSYMB_PACKAGES(it defines part of the symbol inventory itself) but does load amsmath, so the construct flags are set. The two halves are independent, and the existing test that assertedMathPackages::KERNELfor it is updated to say so.Deliberately absent, measured:
nathdefines\binomand\textitself and loads no AMS file at all, so\operatorname,\boldsymbol,\colonand\pmodall stay the kernel's under it and neither answer the flag gives is right — the same call #230 made forlibertinust1math/fourier/siunitxin the symbol list.amsthm,amscd,amsrefs,physics2,unicode-math,esint,cases,mathdots,thmtools,braket,cancel,tikz-cd,diagbox,stmaryrd,wasysym,mathrsfs,eucal,euler,mathpazo,mathptmx,mathdesign,dsfont,bbm,bbold,cmll,fourier,txfonts,pxfonts,mathabx,stix,stix2,tabularray,witharrows,accents,mleftright,units,ntheorem,mathalphaand the layout packages (hyperref,graphicx,xcolor,geometry,booktabs,natbib,biblatex,enumitem,caption,listings,tikz,pgfplots,float,csquotes,microtype,cleveref) all measured as loading no AMS file. 97 packages and 26 classes probed in total.Sub-package loaders, each measured:
amstextalso fromsiunitxandxfrac(both\@ifpackageloaded{amstext}= yes), and from classesrevtex4-1/revtex4-2, which define\textthemselves without any AMS file — indistinguishable to a document, and the gate asks whether pdflatex would error, so they belong there.amsbsyalso frombmand classapa7.\mod, decided#230 left it byte-for-byte. It is now both gated and fixed, because it was wrong in two ways at once.
amsmath.sty910-911:so an opening kern, an ordinary upright
mod— a braced group, not\mathbinlike\bmod— then\,\,and one argument. This compiler emitted a baremodtext atom that took no argument and was classifiedBinby the sameatom_classrule\bmodrelies on: 4mu on each side where amsmath puts 12mu and 6mu, with the argument left outside.Measured with TeX Live 2025 pdflatex at 10pt under amsmath:
$x\mod{y}$$x\mkern12mu\mathrm{mod}\,\,y$$x\mkern12mu\mathrm{mod}\mkern6mu y$$x\mod y$(unbraced)$\mod{y}$$\mkern12mu\mathrm{mod}\,\,y$$x\mathrm{mod}y$(ordinary control)$x\bmod y$(untouched)\if@displayis false inside$...$even under\displaystyle— it is\everydisplaythat sets it — so$\displaystyle x\mod{y}$is 40.14336pt, the inline number. This compiler has no display flag on the atom, exactly as\pmodrecords, so 12mu is the definition that applies; real display math (\[x\mod{y}\], 18mu) is the residual, the same one\pmodalready carries. The unbraced form is one token, which is whatrequired_grouptakes.What this does not gate, and why
\coloneqqand\xleftrightarrow— my probe found these two beyond the 37: undefined in base and amsmath, defined undermathtools. They are not gated here, because no singlemathtoolsflag describes them:newpxmath,kpfontsand classapa7define\coloneqqwithout mathtools, andextarrowsdefines\xleftrightarrowwithout it, so one flag would produce a false "requires mathtools" on real documents. Doing it right needs per-construct provider sets, which the amsmath family does not need. Measured and listed here; a coherent lane of its own.\begin{align}and friends are the same bug on a different axis. An environment is usable only if both\Xand\endXare defined, which is what makesmatrix,pmatrixandcaseslook kernel-defined to a naive\ifcsnameprobe — plain TeX's leftover\matrix/\pmatrix/\casessatisfy the first half and not the second. Probed both halves under TeX Live 2025:equation*,gather,gather*,align,align*,alignat,alignat*,flalign,flalign*,multline,multline*,subequations,matrix,smallmatrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix,cases,aligned,alignedat,split,gatheredare amsmath's (24),dcasesis mathtools', and of the remaining supported environmentsproofis amsthm's,lstlistinglistings',multicols/multicols*multicol's. Not gated: the recovery for a missing environment is a different and much larger design question than for a command (pdflatex typesets the body as ordinary text and then errors again at\end), and it runs through the display/numbering machinery rather thancommand_atom. Deliberately left, with the list measured so the next lane does not have to re-derive it.\bm,\num/\qty/\si/\SI/\ang/\sisetup(siunitx),\color/\textcolor(xcolor) — the other 19 undefined-in-base commands. Each needs its own package flag and loader set; out of this lane, listed so they are not lost.\sgnis a different bug and is not this lane's. It is inOPERATOR_NAMESand renders unconditionally, but it is undefined under every preamble probed — base, amsmath, amssymb, amsfonts, mathtools, amsopn, amsbsy, amstext. No package in TeX Live provides it; it is the canonical\DeclareMathOperatorexample. pdflatex errors on\sgnalways, and this renders it always. Reported, not touched.Gates
Control is a checkout of this branch's own base (
8ca1b1e2, i.e. #230 merged with current main), built and measured the same way in the same environment.crates/compilercargo test --release32-braces-narrow)crates/render-pipelinecargo test --release --no-fail-fast, both trees vendor-swappedcm_less_symbols_are_painted_from_latin_modern_mathfont_family_fixtures_match_pdflatexfootnotes_against_pdflatexinline_math_breaks_against_pdflatexmathbb_paints_from_new_computer_modern_when_bundledpage_frame_against_pdflatexvarnothing_sets_at_msbm_width_and_paints_from_new_computer_modern_when_bundledarray_rows_stack_on_the_strut_with_row_skips_and_columns_at_arraycolsepmath_grids3/3,amsmath_inline11/11)The +5 compiler tests are this change's. Thirteen existing tests changed: each exercised an amsmath construct with
MathPackages::KERNEL, i.e. stood for a document that used\binom/\text/\dfracwithout loading amsmath, and each now passes the packages that document would really have. That is the change working, not a test weakened —every_amsmath_construct_is_diagnosed_without_its_packageasserts the KERNEL behaviour for all 37 by name.Zero font diagnostics on HW1 and HW2, asserted. The corpus run is not zero overall:
article-twocolumnandinput-bibliographycarry 3ec_metrics_unavailablebetween them, becauseectt1000.tfm/ectt1200.tfmare not in this checkout'sapps/mac/Fontstree at all. Identical on both sides, pre-existing, environmental, and untouched by this change — reported rather than rounded to zero.The render gates cannot see
crates/compiler(the pipeline linksvendor/compiler, a pinned mirror atea4ee5c8), so they were measured through an uncommitted full vendor swap ofcrates/compiler/srcovervendor/compiler/src, against a control swapped the same way. The swap also needs #231's one-linetext_kernreverse-lookup fix and a two-argumentparse_tokenscall intests/math_symbols.rs, both consequences of #230, both applied identically to the two trees and neither part of this PR.Pipeline half
There is one, and it is small:
crates/render-pipeline/tests/amsmath_inline.rsand two cases intests/math_grids.rsbuild their documents as\documentclass{article}\begin{document}…and then use\binom,\dfrac,\substack,\operatorname,\textandcases— the exact bug this PR closes, written into the test fixtures. They pass today because the vendor pin predates the gate; they break at the re-pin. Sibling PR adds the\usepackage{amsmath}those documents always needed. It is correct on its own and independent of this one.Measured under the swap, the one pipeline test that changes is
math_grids::array_rows_stack_on_the_strut_…, and it changes on geometry (2\arraycolsep between columns: 14.205…), because its\text{(a)}now falls back to the literal recovery and widens the column.amsmath_inline's eleven tests pass unfixed, which is worth knowing on its own:assert_no_limitation_or_unsupportedfilterscode == "math_limitation" || code.starts_with("unsupported"), butdisplay::Diagnostic::from_compilerrewrites every compiler diagnostic's code to the literal"compiler", so that helper cannot see a compiler diagnostic at all. The construct diagnostic is really there — the sameflashtex-renderbinary on the same document answers\binom requires \usepackage{amsmath}. Reported, not fixed here; it is why those fixtures could describe invalid LaTeX without any test noticing.Every committed
.texin the repository was scanned: 0 documents use an amsmath construct without loading a package that provides it. Real documents load their packages, which is why no corpus fixture moved.End to end
flashtex-compileron the branch, one runtime-v1compileper document:\documentclass{article}+\dfrac \text \binom \mod \left\lvert…\right\rvertamsmath,amstext)\usepackage{amsmath}\usepackage{siunitx}+\text+\binom\binomonly — siunitx gives\textand nothing else\usepackage{bm}+\boldsymbol+\operatorname\operatorname requires \usepackage{amsopn}only\documentclass{amsart}+\dfrac+\operatorname\frac12 \dots \stackrel \overline \iff \bmod \pmod \mathbfwith nothing loadedDraft; not for merge.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu