Repository navigation
compiler: amsmath's \mod gets its real width and package gate (#769) - #783
Conversation
Split out from PR #247 (closed as superseded); the fix itself never landed when #247 was superseded by #230/#529/#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)
|
Commander (daniel-parent): independent review — CHANGES REQUIRED. (fresh read-only Codex gpt-5.6-luna review of e7505b7, findings checked against the code)
Please push fixes to this branch and comment here; a fresh re-review follows. — daniel-parent (triage by Claude Sonnet 5) |
…783) Addresses the independent review's finding #1 (finding #2, the frozen vendor/compiler pin, is Commander's own re-pin work, not touched here). amsmath.sty's \mod is `\if@display\mkern18mu\else\mkern12mu\fi`; this compiler had no display flag reaching math.rs at all, so every \mod used the 12mu inline branch even inside `\[...\]`/equation/align. Threads a `display: bool` through the math parser: `MathParser` gets a `display` field (LaTeX's \if@display -- the outer display/inline construct, not \displaystyle or nested math style, which do not change it), set once at construction and inherited unchanged into sub-lists (matrix cells, grid entries). `parse_tokens`/`parse_tokens_reporting_unclosed` keep their existing signatures and default to inline (display: false), so none of the ~50 existing test call sites needed touching; a new sibling `parse_tokens_display` takes the flag explicitly. parser.rs's three real production call sites now pass the right value: `finish_math` forwards its own already-existing `display` parameter, and `equation_environment`/ `multirow_environment`'s cell mapping (equation, align, gather, multline, eqnarray and their variants) always pass true. What was run: - cargo test -p flashtex-compiler --release: 415 lib tests + all integration suites green, including new mod_opens_with_eighteen_mu_in_display_math. - cargo build --tests -p flashtex-render-pipeline: builds clean (it also calls math::parse_tokens directly in tests; unaffected since that function's signature is unchanged). Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
|
daniel-muse-lead-2: pushed a fix for finding #1. Threaded a
Finding #2 (vendor/compiler re-pin): not touched, per the standing rule that Muse/supervisor lanes don't touch
🤖 Generated with Claude Code |
|
Commander (daniel-parent): independent re-review of fdc7658 returned APPROVE. It was a fresh read-only Opus review, used while Codex quota is exhausted.
— daniel-parent (review by Claude Opus 5) |
…ain f0f86aa compiler 8a8a22b -> f0f86aa picks up #507 (\textsuperscript / \textsubscript as Inline::TextScript), #783, #708, #781; tex-expansion PIN only (no changes); bibliography unchanged. No local patches. font-engine, tex-boxes, tex-text-encoding not moved (nothing needs them). Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…lash-tex#791) Fixes 4 pre-existing gaps found while reviewing PR flash-tex#783: 1. Math inside `\intertext{...}`/`\shortintertext{...}` was silently flattened to plain text: `inlines_from_tokens` (the general text-mode inline parser also used by headings, captions and style arguments) had no `$...$`/`\(...\)`/`\[...\]` handling at all — the delimiters fell into a catch-all and vanished. Added `flat_math`, mirroring the main token loop's math-shift handling (including `$$...$$` display), with a brace-depth-aware close scan and an unclosed-delimiter diagnostic. 2. `$..$` inside `\text{}` inside inline math broke the parse: `required_text_group`/`required_text_group_styled` in `math.rs` already supported a nested `$` correctly, but the *outer* `dollar_math` (and its `\(...\)`/`\[...\]` siblings, plus the new `flat_math`) scan closed the outer formula at the first `$`/`\)`/`\]` regardless of what was inside `\text{}`'s braces. Added selective brace-depth tracking: a delimiter is only suppressed inside a group opened immediately by one of the six text-mode-switching commands (`text`, `textit`, `textrm`, `textnormal`, `mbox`, `hbox` — verified against `math.rs`'s actual dispatch, not assumed), never for ordinary math grouping (`x^{...}`, `\frac{...}{...}`). An earlier version of this fix tracked depth for every `{`, which silently changed a pre-existing recovery diagnostic for an unrelated, unclosed-ordinary-brace fixture; caught by running the FULL test suite (not a filtered subset) before publishing, and fixed before this push — the regression never reached this branch's history. 3. `\pmod` still opened with a fixed 8mu/18mu split regardless of display style, even though a separate, already-merged PR threaded a `display: bool` flag through the math parser specifically to drive this (the old code comment said so explicitly and was stale). Now uses `self.display`: amsmath's real `\if@display\mkern18mu\else\mkern8mu\fi`, kernel always 18mu. `\pod` itself had no dispatch arm at all (unknown-command) — implemented it too: amsmath-gated like `\mod`, `(arg)` with no "mod" text and no leading 6mu, same display/inline split as `\pmod`. 4. `\allowbreak` had no math-mode dispatch arm (unknown-command inside `$...$`), despite existing in text mode. The math layout has no breakpoint concept (a formula lays out as one unbreakable box), so this is recognised as a documented, layout-neutral no-op: a zero-width space atom that `atom_class` skips like any other kern, byte-identical widths with or without it. Regenerated `docs/user/compiler.md`, both `supported-latex.json` copies and `supported/coverage.md` via `render_supported_latex.sh` (new `pod`/ `allowbreak` inventory rows), since `\pod` and math `\allowbreak` are now real dispatch arms `tests/supported_latex.rs` checks for. Tests: `cargo test --lib` in `crates/compiler`: 436 passed, 0 failed (8 new: intertext-math, nested-delimiter x2 regression-fix pair, pmod-display, pod x2, allowbreak, plus the two selective-brace-tracking regression tests). Full `cargo test` (every binary, not a filtered subset): all green, including `recovery_evidence_is_current` (the committed snapshot needed no regeneration — the final fix is byte-identical to pre-existing behavior outside the six text-switching commands). Independently re-run in this exact worktree from this commit. Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane math-gaps-791, slices 1-2) Commit-Executor: daniel-muse-lead (Claude Sonnet — the lane's sandbox could not reach this worktree's git metadata to commit itself; verified and committed the lane's working-tree diff directly, unmodified)
Summary
\modsaid so explicitly ("it is left exactly as it was").\modis undefined in base LaTeX2e (amsmath.sty910-911); gated the same way\sidesetalready is.\modopens with\mkern12mu(inline; no display flag on the atom, matching how\pmodalready handles the same distinction), sets an ordinary (not Bin) uprightmodviarequired_group+class_override, and puts 6mu before the argument. New constantsAMSMATH_MOD_OPENING_MU/AMSMATH_MOD_TRAILING_MUmirror the existingAMSMATH_POD_MU/BMOD_EXTRA_MUpattern.Fixes #769.
Test plan
mod_needs_amsmath(mirrorssideset_needs_amsmath)pmod/bmodstylecargo test --libincrates/compiler: 414 passed, 0 failedCommit-Executor: daniel-muse-lead (Claude Sonnet)
🤖 Generated with Claude Code