Skip to content

compiler: a package-provided math symbol needs its package loaded - #230

Merged
GoKubar merged 6 commits into
mainfrom
agent/kabir-claude/math-package-gating
Sep 14, 2026
Merged

GoKubar merged 6 commits into
mainfrom
agent/kabir-claude/math-package-gating

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Compiler half of the package-gating lane. Sibling pipeline PR is independent. Stacked on #198, whose MathPackages this extends; that branch is merged in as this branch's second parent, so the diff below contains #198's commit as well as this one. Review 543bde5c.

The problem

math::command_atom applied the amssymb/amsfonts symbol table unconditionally. Nothing checked that the document wrote \usepackage{amssymb}, so \square, \nleq, \boxdot and the other 218 commands the table answers rendered happily in a document that loaded no package at all.

I probed every one of them with \ifcsname under TeX Live 2025 pdflatex, with an empty preamble and then under amssymb, amsfonts, latexsym and amsmath:

commands
supported math commands probed 535
defined by base LaTeX2e 254
undefined in base LaTeX2e, provided by amssymb/amsfonts 225
undefined in base LaTeX2e, provided by amsmath 37

So it was the whole table, not a few symbols: for 225 commands pdflatex answers ! Undefined control sequence where this compiler drew a glyph. No name in the table collides with a \not@base stub, and latexsym provides nothing this compiler supports, so the divergence is uniform.

The gate

Each symbol now carries the file that declares it. That is generated, not hand-written: gen_amssymb.py collects declarations from both .sty files before the dedup that used to hide amsfonts.sty 141–147 re-declaring \square, \lozenge, \rightsquigarrow, \vartriangleright, \vartriangleleft, \trianglerighteq and \trianglelefteq. The regenerated table is byte-identical to the committed one apart from the new field (checked by stripping the field and diffing), so no oracle data moved.

MathPackages (from #198) gains amssymb and amsfonts beside amsmath, and the fallback arm diagnoses the missing \usepackage instead of rendering. The split the generator produces agrees with pdflatex on all 218 commands: 15 names + 7 pieces from amsfonts.sty, the rest from amssymb.sty.

The same gate covers the commands that have their own arm rather than a table row — \varnothing, the three dashed arrows, \mathbb/\mathfrak and the obsolete \Bbb/\bold. \mathbf, which \bold stands for, is the kernel's and stays unconditional.

Which package provides what was measured, not assumed. Each candidate was compiled and probed for \nleq (amssymb only), \ulcorner (also amsfonts) and \binom (amsmath):

  • Load amssymb (so also amsfonts): amssymb, txfonts, pxfonts, newtxmath, newpxmath, mathabx, kpfonts, MnSymbol, cool; classes acmart, beamer.
  • Load amsfonts only: amsfonts; classes amsart, amsbook, amsproc.
  • Deliberately absent: libertinust1math, fourier and siunitx define part of the inventory themselves without either AMS package (\nleq yes, \ulcorner/\yen/\mathfrak/\dashrightarrow no), so neither flag describes them. amsthm, amsopn, amsbsy, amscd, amstext, bm, unicode-math, stmaryrd, wasysym, esint, mathrsfs, eucal, euler, mathpazo, mathptmx, mathdesign, concmath, dsfont, bbm, bbold, cmll, physics, mathtools and 20 more measured as providing neither.

The negative behaviour, measured

\angle and \hbar are the only two commands of this inventory that base LaTeX2e does define, as composites amsfonts replaces with one glyph. Without the package they now keep the kernel advance:

box kernel under amssymb
\hbox{$\angle$} 6.37344pt (ht 6.56220) 7.22223pt (ht 6.92240)
\hbox{$a\angle b$} 15.95099 16.79977
\hbox{$\hbar$} 5.76172pt 5.40280pt
\hbox{$a\hbar b$} 15.33926 14.98035

The context rows move by exactly the width difference, so neither changes atom class. The \hbar composite reproduces exactly from its pieces: OT1 macron 5.00002 + \mkern-9mu −4.99988 + math italic h 5.76158 = 5.76172. The kernel \angle is an \ialign of rules and is size-invariant — 6.37344pt in \scriptstyle too, where amssymb's scales to 5.81946.

Only the advance is forced; the nearest Latin Modern Math character stays the glyph either way, because the kernel \angle is a rule drawing with no character to name. The compiler's own layout honours width_em; the render pipeline reads it only as the \varnothing sentinel flag, so through the full stack these two advances are not yet forced — a follow-up, called out below.

Every other command in the table is diagnosed, because pdflatex errors. Recovery is the existing literal one, with the actionable half in the message: \square requires \usepackage{amssymb}.

Tier 1 of #198's audit

Measured before and after against TeX Live 2025 pdflatex at 10pt.

\pmod inline — kernel \mkern18mu, amsmath's \pod \if@display\mkern18mu\else\mkern8mu\fi:

box kernel amsmath
$a\pmod{y}$ 50.82503 45.26960
$a\mkern18mu(\mathrm{mod}\mkern6mu y)$ 50.82503 50.82503
$a\mkern8mu(\mathrm{mod}\mkern6mu y)$ 45.26960 45.26960
$\pmod{y}$ 45.53914 39.98372

Setting \@displaytrue by hand puts amsmath back on 50.82503, confirming display is 18mu under both; we hardcoded 18mu, so only inline moves.

\bmod — not a bare \mathbin: latex.ltx 15703-15706 cancels \medmuskip and puts \mkern5mu in its place, so it is 1mu wider on each side than its Bin class. Package-independent (identical under kernel, amsmath and amssymb):

box pdflatex ordinary-mod control delta
$a\bmod b$ 34.29970 28.74428 10mu
$\bmod b$ 24.56947 23.45839 2mu
$\bmod$ 20.27782 19.16673 2mu

$a\mkern5mu\mathrm{mod}\mkern5mu b$ is 34.29970 exactly. The 2mu rows are the Bin degrading to Ord with no left operand, which the compiler's spacing_classes already models and which the new kerns leave intact. Residual: the two \nonscripts drop the −4mu in script styles, where the Bin class contributes nothing either, so pdflatex keeps the full 5mu there and this keeps 1mu. That needs a style-aware kern, which no atom here carries; it is stated in the code.

Text-mode \,/\! — amsmath renews them to .1667em against the kernel's .16667em:

box kernel amsmath delta
\hbox{a\,b} 12.22230 12.22261 +20sp
\hbox{a\!b} 8.88887 8.88857 −20sp

24sp at 12pt. \:/\; and their negatives are byte-identical under both, and the math-mode \mskip forms do not move ($a\,b$ identical) — all asserted.

\widehat/\widetilde are a newly measured fourth case, not in #198's audit: amsfonts changes them too, but only in height, and only over wide arguments — \widehat{abcdefg} ht 10.13890 → 10.56485, \widetilde{abcdefg} 10.13890 → 11.31479, while every width and \widehat{abc} are identical. That is math-layout work, not a compiler arm; recorded here, not implemented.

Gates

gate control this branch
crates/compiler cargo test --release 472 passed, 0 failed (94e3caa5, the same base merged with the same main, same worktree) 481 passed, 0 failed
amsmath corpus 59/59 59/59
amssymb corpus 38/39 (32-braces-narrow, 1.012 bp) 38/39, same fixture
both corpus output files — byte-identical to the control
HW1 / HW2 3 / 3 pages, 0 errors, 0 overfull 3 / 3 pages, 0 errors, 0 overfull
real-world corpus, 12 fixtures — identical status and diagnostic set, fixture by fixture

Zero font diagnostics asserted on every render gate. The +9 tests are this change's.

No real-world fixture gains a requires \usepackage diagnostic: they all load their packages, including through the \usepackage{amsmath,amssymb} comma form, which the parser splits and folds in per name.

The render gates cannot see crates/compiler (the pipeline depends on vendor/compiler, a pinned mirror), so they were measured through an uncommitted full vendor swap of crates/compiler/src over vendor/compiler/src, against a control that swaps in the base's sources the same way. The swap is neutral: the control's numbers are identical to the committed pin's.

Unblocks #212

#212 holds back six amsfonts symbols and says so explicitly: "math::command_atom applies the amssymb table unconditionally … these six would render as their msam/msbm glyphs even in a document that loads no package, where pdfLaTeX would give the kernel composite for \angle/\hbar/\rightleftharpoons and an error for the other three. Fixing it needs the parser's packages list plumbed into the math layer."

That is what this PR does, and it does it in the shape #212 needs:

Two things #212 will need on rebase: its six names leave SKIP in gen_amssymb.py, which now also computes provider (\angle, \hbar, \mho, \sqsubset, \sqsupset and \rightleftharpoons are all declared in amsfonts.sty, so they come out Provider::Amsfonts — correct, and matching the probe); and angle_and_hbar_keep_the_kernel_composite_without_amsfonts asserts width_em == None on the loaded side, which becomes the ams row instead.

What this does not do

  • The 37 amsmath-provided constructs — \text, \binom, \boxed, \dfrac, \operatorname, \tag, \substack, \xrightarrow, \mod, … — are undefined in base LaTeX2e for exactly the same reason and are still applied unconditionally. They are a coherent follow-up lane of their own; gating them changes far more documents than gating symbols does, and the full measured list is in this PR's probe output. \mod in particular is a different command from \bmod with a different kern ($x\mod{y}$ 40.14336pt under amsmath) and is deliberately left exactly as it was.
  • The kernel \angle/\hbar advances reach the compiler's own layout but not the render pipeline, which reads width_em only as the \varnothing sentinel flag. Forcing them there needs two more sentinels on the VARNOTHING_SENTINEL pattern (mathfont.rs, mathtex.rs, typeset.rs).

Draft; not for merge.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 6 commits September 13, 2026 15:19
…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
`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
GoKubar added a commit that referenced this pull request Sep 14, 2026
…rs all nine

Self-correction, and it reverses this lane's recommendation.

The first version of the README claimed aliasing the nine latexsym commands to
amssymb "changes the atom class of four of them", and recommended transcribing
eleven lasy10 advances as constants to avoid that. It also said \Join has no
amssymb equivalent at all. Both were wrong, and the error was reading
amssymb.sty without reading amsfonts.sty's compatibility block.

amsfonts.sty 151-162, guarded by
`\@ifpackageloaded{latexsym}{\@tempswafalse}{\@tempswatrue}`, provides all
nine itself when latexsym is not loaded -- and it keeps the kernel classes.
\lhd \unlhd \rhd \unrhd are re-declared \mathbin on the same AMSa slots the
\vartriangle* relations use, rather than \let to those relations, so the class
never changes. \Join is there too, at line 161, as a \mathrel composite of
AMSb "6F and "6E with \mkern-13.8mu.

Measured under \usepackage{amssymb} with no latexsym, every class is correct
and six of the nine are advance-exact: \mho, \leadsto, \lhd, \unlhd, \rhd and
\unrhd are all +0.00000 against lasy. Only three differ -- \Box +0.30556,
\Join +0.66690, \Diamond -1.25004.

So the recommendation becomes much cheaper and strictly more correct: provide
all nine through the amsfonts declarations gen_amssymb.py already parses,
gated on amssymb/amsfonts via #230's provider field. msam/msbm metrics are
already bundled and \mathbb already draws from msbm, so nothing new has to be
bundled, licensed or transcribed. The 1.11111 pt class error stays in the
README as the reason not to use the \vartriangle* names.

One exception the new table pins: with BOTH packages loaded, amsfonts leaves
latexsym's design alone for every name except \mho (lasy ht 6.83331 -> msbm
6.88889, advance unchanged), because amsfonts 101's \ams@DeclareMathSymbol is
`\global\let#1\undefined` then re-declare, an unconditional override sitting
outside the \if@tempswa guard. Load order does not change it.

measure.py grows a table for the nine under amssymb/amsfonts/both so every
number above is reproducible, and labels the old comparison as the naive alias
it is.

Implementation-Agent: Claude Opus 5 (engine-engineer, kernel math gap lane, linux-primary)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar marked this pull request as ready for review September 14, 2026 01:18
@GoKubar
GoKubar merged commit 9fb6599 into main Sep 14, 2026
18 of 20 checks passed
GoKubar added a commit that referenced this pull request Sep 14, 2026
vendor: re-pin compiler past #230, and switch package gating on
GoKubar pushed a commit that referenced this pull request Sep 15, 2026
…ositions, new compiler lanes (#246)

The board still said "main ad71b64" with FT-050..055 as the queue. It now
carries the FT-060..067 outcomes, the two standing performance programs
(FT-070 Kabir, FT-071 Mac), the dispositions agreed on issue #2 for the
53 open PRs (Kabir's 2026-09-14T00:10Z triage), the merge order #233 ->
#241 -> #230 -> #231 -> #232, and the three unclaimed compiler lanes
#242/#243/#244 that close the last real-world corpus errors. Historical
rows are kept below.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code

Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@GoKubar
GoKubar deleted the agent/kabir-claude/math-package-gating branch September 16, 2026 04:17
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)
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