Repository navigation
compiler + math-layout: amsmath \sideset with pdflatex geometry — a left-scripts slot (stacked on #470) - #581
Conversation
What changed: - Added compiler regression tests for nested math in tags/text, text styles, unsupported commands, tag glue, and eqref labels. - Added math-layout width/style-size regression tests. What was run: - test result: FAIL (expected): CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-tag cargo test --manifest-path crates/compiler/Cargo.toml --test text_runs - test result: FAIL (expected): CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-tag cargo test --manifest-path crates/math-layout/Cargo.toml --test text_runs Next step: - Add the minimal text-run IR and parser/layout support. Implementation-Agent: codex gpt-5.6-luna (max) Commit-Executor: codex (this session) Lane-Owner: daniel-parent (mac-m5pro-dq222)
What changed: - Add compiler and math-layout TextRun/TextPiece IR while retaining plain Nucleus::Text output. - Parse nested dollar and parenthesized math, text faces, tags, starred tags, and custom eqref labels. - Lay out nested math in text-size hboxes and recurse through incremental/source-span paths. What was run: - test result: ok. 6 passed; 0 failed; compiler text_runs - test result: ok. 8 passed; 0 failed; supported_latex inventory - test result: ok. 12 passed; 0 failed; math-layout unit tests - test result: ok. 28 passed; 0 failed; math-layout golden tests - test result: ok. 2 passed; 0 failed; math-layout text_runs - test result: ok. 327 passed; 0 failed; compiler unit tests - test result: ok. 2 passed; 0 failed; corpus_gate - test result: ok. 4 passed; 0 failed; hw1_preamble - test result: ok. 1 passed; 0 failed; 1 ignored; hw2_gate - test result: ok. render-pipeline vendored build - test result: ok. pdflatex oracle widths 21.86809pt, 5.00002pt, 56.61810pt Next step: - Push this green PR1 step; leave render-pipeline rich display-list integration for PR2. Implementation-Agent: codex gpt-5.6-luna (max) Commit-Executor: codex (this session) Lane-Owner: daniel-parent (mac-m5pro-dq222)
This addresses the independent review of 25c63aa. - Restores main's 2-quad tag gap as INTERIM_TAG_GAP_EM until PR 2 places tags flush right, so \\tag{1} is no longer glued to the formula. - \\text inside math inside \\text shares MAX_MATH_DEPTH and is diagnosed at depth 40 instead of overflowing the stack. - \\eqref to a rich \\tag{hi $x^2$} resolves to the flattened tag text (hi x²). References carry strings, which is documented as a limitation. - End-to-end parser and layout tests: tag widths, \\textbf{$x$}, unbalanced $, an unsupported command inside $, \\tag* and \\eqref. The automatic equation number with \\tag is unchanged; main shows it too. What was run (full crates): cargo test --manifest-path crates/compiler/Cargo.toml and crates/math-layout/Cargo.toml. Every test result is ok (compiler lib 327 passed). Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a148-e56e-7722-b0a8-0436a343ed75 (resumed) Commit-Executor: daniel-parent (the resumed Codex session cannot write .git) Lane-Owner: daniel-parent (mac-m5pro-dq222) Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ag-textrun # Conflicts: # crates/compiler/src/parser.rs
…ls and fractions; \\cref on tagged equations
This is the final fix round from the second independent review.
- \\tag* no longer strips parentheses, so \\tag*{(custom)} + \\eqref gives ((custom)).
- Flattening for \\eqref uses rendered glyphs where one exists (alpha_1 gives the Greek
letter with a subscript one) and falls back to source text for radicals and
fractions, never dropping them.
- Regression test: \\cref on a \\tag{A} equation gives eq. (A).
- The 24.88pt width assertion is labelled a legacy Core14 compiler-route pin, not
a pdflatex oracle (pdflatex 29.64589pt; the real comparison is PR 2).
What was run (full crates): cargo test for crates/compiler and crates/math-layout.
Every test result is ok (compiler lib 334 passed).
Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a148-e56e-7722-b0a8-0436a343ed75 (resumed)
Commit-Executor: daniel-parent (the resumed Codex session cannot write .git)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ag-textrun # Conflicts: # crates/compiler/src/math.rs
…ipts)
What changed:
- `Atom::left_scripts: Option<LeftScripts>` (and `Atom::with_left_scripts`):
when set, the atom is laid out as amsmath.sty 921-929's
`\mathop{\box4\box6}`: box 0 is the operator alone in \displaystyle
(measured for height/depth), box 4 an empty vbox of that height/depth
carrying the left pair in \displaystyle (Rule 18a from the operator's
height and depth, both scripts left-aligned), box 6 `#3\nolimits#2` in
\displaystyle. The `\hbox to\dimen@{}` Ord and the `\kern-\dimen@` cancel;
the list builder supplies an empty Ord atom for the thin space.
- No new Nucleus variant, so no downstream exhaustive match breaks; the
unpacking, glue and accent patterns skip atoms that carry left scripts.
- tests/sideset.rs pins pdflatex \showbox numbers (inline and
\displaystyle): `\sideset{_a^b}{_c^d}\sum`, `\sideset{_{ab}^b}{}\sum`,
`x\sideset{}{'}\sum x`.
What was run:
- cargo test --test sideset: test result: ok. 3 passed; 0 failed
- cargo test (flashtex-math-layout): every binary `test result: ok.`, 0 failed
Next step: compiler \sideset parsing gated on amsmath; render-pipeline
conversion draft.
Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ucleus::SideSet)
What changed:
- `\sideset{#1}{#2}{#3}` (amsmath.sty 921-929) parses to two atoms, as
amsmath typesets it: an empty ordinary Group (`\hbox to\dimen@{}`) and a
`Nucleus::SideSet { operator, left_superscript, left_subscript }` atom of
class Op. `#2` attaches to the last atom of `#3` (`#3\nolimits#2`);
scripts after `#3` are the \mathop's own. Script groups take `_`, `^`
and primes (`\sideset{}{'}\sum`); other material and duplicate scripts
are diagnosed.
- Gated on amsmath: without it, "\sideset requires \usepackage{amsmath}"
(pdflatex: `! Undefined control sequence`).
- SideSet arms in every exhaustive match (reference text, span end,
atom class, approximate layout, shift_atom, shift tests, incremental
shift_math_list, siunitx respan_atom). `prime_script` factored out of
list parsing.
- Inventory: \sideset moves from known-unimplemented to supported; the
hw1 preamble test now expects it to typeset silently. Generated
artefacts regenerated with render_supported_latex.sh.
What was run:
- cargo test --lib sideset_tests: test result: ok. 5 passed; 0 failed
- cargo test (flashtex-compiler): 56 `test result: ok.` lines, 0 failed
Next step: render-pipeline conversion (feature-gated) and scratch re-pin
check against pdflatex.
Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
daniel-parent independent review (subagent) Verdict: CHANGES NEEDED (one real geometry bug, narrowly scoped; everything else checks out) Method: detached worktree at #581's head (
Everything else — the amsmath gate, the new |
What changed: - `takes_display_limits()` in crates/compiler/src/math.rs gains a `Nucleus::SideSet` arm: it takes limits exactly when the inner operator (the last atom of `#3`) would. Before, it fell through to `false`, so `\[\sideset{_a^b}{}\sum_{i}\]` put `i` at the same corner offset as inline. - New test `sideset_trailing_script_is_a_display_limit_like_its_operator` compares inline vs display placement of `i`. pdflatex `\showbox` (amsmath, 10pt): inline `i` at x=20.95 shifted down 6.50; display `i` centred under `∑` at x=10.65, 13.30 below. The test asserts that direction (display is left of and below inline) and that the display limit baseline matches bare `\sum_{i}`. It fails without the arm (display y == inline y == 12.2967). What was run: - cargo test -p flashtex-compiler (56 suites): 674 passed, 0 failed - cargo test --lib (compiler): test result: ok. 345 passed; 0 failed; 0 ignored - cargo test -p flashtex-math-layout (10 suites): 71 passed, 0 failed Next step: - pdflatex also gives `\displaystyle\sideset{_a^b}{}\int_{i}` a centred limit (amsmath's outer `\mathop` has default `\displaylimits`, so the inner `\int`'s `\nolimits` does not carry over). This arm follows the inner operator as requested in review; widen it to every `\sideset` if we want that case too. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
daniel-parent (subagent): review fix pushed as 0c520d5, corrected in fae2b3a
Test results:
|
What changed: - The `Nucleus::SideSet` arm of `takes_display_limits()` is now unconditionally `true`. amsmath wraps `\sideset` in an outer `\mathop` with the default `\displaylimits`, so pdflatex puts limits on it in display style whatever the inner operator is. That includes `\int`, whose own `\nolimits` stays inside. The layout only calls this in display style at level 0, so text style keeps corner scripts. This replaces 0c520d5's inner-operator rule, which was wrong. - The test is renamed to `sideset_trailing_script_is_a_display_limit_whatever_the_operator` and adds `\sideset{_a^b}{}\int_{i}`. pdflatex `\showbox` (amsmath, 10pt): inline `i` at x=16.50, shifted down 9.61; display `i` centred under `∫` at x=8.42, baseline 16.41 below. It also checks that a bare `\int_{i}` keeps its corner script in display style. What was run: - cargo test --lib (crates/compiler): test result: ok. 345 passed; 0 failed; 0 ignored - cargo test (crates/math-layout): 10 suites, 71 passed, 0 failed Next step: - None for this review item. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
… regen supported inventory main took 71 merges today including #470's squash; the branch carried #470's original commits. Resolved compiler math.rs/parser.rs/vocabulary.rs and math-layout layout.rs/lib.rs hunk by hunk (kept main's Lap/underbar/comment additions alongside the branch's SideSet work, dropped the duplicated make_text_styled and text_space copies the auto-merge produced), then regenerated the supported-latex inventory against the merged compiler (amsmath 45/102, total 543/1314). compiler: 876 tests, 0 failures. math-layout: 74 tests, 0 failures. --locked release builds clean. Implementation-Agent: fable-daniel-takeover Commit-Executor: fable-daniel-takeover (direct; Cursor usage limit)
…ideset-pipeline What changed: - #581's compiler `Nucleus::SideSet` and math-layout `Atom::left_scripts` have landed on main by another route, so every conflicted hunk in crates/compiler and crates/math-layout was this branch's copy of material main already carries. All of them resolved to main's side. - crates/compiler/src/math.rs (6), parser.rs (1), vocabulary.rs (1), crates/math-layout/src/layout.rs (2). - crates/math-layout/src/cm.rs auto-merged a second copy of `fn text_space(&self, size: SizeClass)` (E0201, duplicate definition); the duplicate was removed so the file matches main. - Generated artefacts (docs/user/compiler.md, crates/compiler/supported/{supported-latex.json,coverage.md}, the bundled apps/mac copy) were taken from main and regenerated with `sh crates/compiler/scripts/render_supported_latex.sh`. - What survives from this branch is only its own payload: the pipeline-side consumption of math-layout's left scripts, feature `amsmath-sideset`. `git diff origin/main` is now exactly crates/render-pipeline/Cargo.toml, src/incremental.rs, src/typeset.rs and tests/amsmath_sideset.rs (4 files, +220). What was run: crates/math-layout: cargo build --lib -> Finished crates/render-pipeline: cargo build --lib --tests -> Finished crates/render-pipeline: cargo test --lib test result: ok. 164 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out amsmath_inline: test result: ok. 11 passed; 0 failed; 0 ignored displaystyle_switch: test result: ok. 3 passed; 0 failed; 0 ignored math_ellipsis: test result: ok. 5 passed; 0 failed; 0 ignored math_operator_limits: test result: ok. 6 passed; 0 failed; 0 ignored math_operator_thin_space: test result: ok. 3 passed; 0 failed; 0 ignored math_symbols: test result: ok. 18 passed; 0 failed; 1 ignored math_text: test result: ok. 7 passed; 0 failed; 0 ignored amsmath_sideset: test result: ok. 0 passed; 0 failed; 0 ignored (the whole file is behind `amsmath-sideset`, which is off until the re-pin) Next step: - Still blocked on the vendor/compiler + vendor/math-layout re-pin (#711); until it moves, the feature cannot be switched on by default and the end-to-end behaviour cannot be shown. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed: - `crates/render-pipeline/Cargo.toml` declares a new off-by-default feature `compiler-node-surface`. It carries no behaviour of its own: every arm it adds is the inert answer the pipeline already gave for a compiler node the current pin (`c95977d6`) cannot produce. - The pipeline's exhaustive matches and node constructors now cover main's compiler surface behind that feature: `parser::Block::Penalty`/`Tabbing`, `parser::Inline::ThePage`/`PageNumbering`/`TabStop`/`TabJump`/`Marginpar`/ `Penalty`/`PagePenalty`/`Discretionary`, `VSpace`/`HSpace` glue components, `math::Nucleus::TextRun`/`SideSet`/`Lap` and `math::Accent::Mathring` (compiler flash-tex#549, flash-tex#551, flash-tex#555, flash-tex#568, flash-tex#581, flash-tex#583, flash-tex#587, flash-tex#606, flash-tex#616). `adapter::vspace_block` is a new cfg'd constructor beside the existing `line_break_inline`; the one open-coded `Inline::LineBreak { .. }` left in the `\opening` lowering now goes through `line_break_inline` too. - `tabbing` is lowered to flush-left paragraphs with one `unsupported_block` limitation, the way `LetterBlock` is, so no row is dropped by the re-pin. - `docs/integration/repin-runbook.md`: the exact re-pin commands, the three vendor directories that must move (`compiler`, `tex-expansion`, and a new `bibliography`), the lockfile and `#[ignore]` edits `--locked` CI needs, the measured test deltas and the PRs the pin unblocks. No file under `vendor/` is touched: the vendor swap used to measure all of this was scratch-only and reverted. `git diff --stat origin/main...HEAD` contains zero `vendor/` paths. What was run: Whole `crates/render-pipeline` suite, CARGO_BUILD_JOBS=4, --no-fail-fast: origin/main, pinned vendor, feature off: 469 passed, 13 failed this branch, pinned vendor, feature off: 469 passed, 13 failed (same 13) this branch, vendor re-pinned, feature on: 485 passed, 0 failed The 13 red-on-main tests (letter_class_geometry x5, frame_env, underline_sout x4, uline x2, xcolor_oracle) all pass after the re-pin. Two re-pin-gated #[ignore]s also pass against the re-pinned vendor: test frame_draws_a_rule_border_around_its_content ... ok test coloneqq_decomposes_like_mathtools ... ok crates/flashtex-cli against the same re-pinned vendor: test result: ok. 58 passed; 0 failed cargo check --all-targets on this branch at the current pin: 0 errors. Next step: The integration lane applies docs/integration/repin-runbook.md section 3 -- swap the three vendor trees, move `compiler-node-surface` (and `linebreak-skip`) into `default`, refresh both Cargo.locks, drop the two `#[ignore]`s, update vendor/VENDORING.md. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…through their PINs (#953) d5cedcb edited vendor/math-layout/src/{cm,mathlist}.rs and vendor/pdf/src/encoding.rs directly (the angle-bracket delimiter aliases), which VENDORING.md forbids; scripts/check-vendor-pins.sh FAILed integrity on both (pdf's a9ec24a pin had also stopped matching the mirror's exact.rs/v2.rs). Both mirrors are now `git archive d5cedcb crates/<name>` exports, byte-identical to main's live crates apart from PIN, so the aliases reach the pipeline through the pin. math-layout also picks up the four crates/math-layout commits the old pin lacked (#470 TextRun, #560 ord_pair, #581 sideset, #646), all additive: no pipeline source changed. Verified: check-vendor-pins.sh reports math-layout and pdf "up to date (ok)"; cargo test --release on crates/render-pipeline 750 passed / 0 failed with these mirrors and the reconciled compiler mirror of the next commit. Implementation-Agent: Claude Code (mac-claude-a) Commit-Executor: git via Claude Code Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
Stacked on #470: the branch starts from
agent/daniel-parent/tag-textrun, which addsNucleus::TextRunat the same match sites. Review or merge #470 first. Until it merges, this diff also shows #470's commits.Supersedes the geometry in #512 (muse-lead). #512 was used only as a reference; none of its constants or code were reused.
What
amsmath
\sideset{#1}{#2}{#3}(amsmath.sty921-929), with pdflatex's geometry:math-layout: a left-scripts slot.
Atom::left_scripts: Option<LeftScripts>(builder:Atom::with_left_scripts).#3, its ownsuperscript/subscriptare#2, and the slot is#1. It is laid out as\mathop{\box4\box6}:#3alone in\displaystyle: the display-size glyph, centred on the axis. Only its height and depth are used.#1in\displaystyle: Rule 18a starts both shifts from the operator's height and depth, and both left scripts start at the box's left edge (left-aligned).#3\nolimits#2in\displaystyle.\@mathmeasureis a fresh display-style formula.\hbox to\dimen@{}and\kern-\dimen@cancel, so the slot drops both. The list builder supplies an empty Ord atom in front instead. That gives the thin Ord-Op space and TeX's spacing against the neighbours:x\sidesetgets no space before the box.Nucleusvariant, so no downstream exhaustivematchonmath_layout::Nucleusbreaks. The unpacking, glue and accent patterns inside math-layout skip atoms that carry left scripts.Compiler.
\sidesetparses to amsmath's two atoms: an empty ordinaryGroup(\hbox to\dimen@{}), thenNucleus::SideSet { operator, left_superscript, left_subscript }of class Op.#2attaches to the last atom of#3.#3are the\mathop's own._,^and primes (\sideset{}{'}\sum). Other material and duplicate scripts are diagnosed.\sideset requires \usepackage{amsmath}(pdflatex:! Undefined control sequence).SideSetarms are added to every exhaustive match: reference text, span end, atom class, the approximate layout,shift_atom, the shift tests, incrementalshift_math_listand siunitxrespan_atom.prime_scriptis factored out of list parsing.\sidesetmoves from known-unimplemented to supported, and the hw1 preamble test now expects it to typeset silently. The generated artefacts were regenerated withrender_supported_latex.sh.Why
The #512 review found every position off by 1.7 to 10pt:
Oracle
/Library/TeX/texbin/pdflatex, 10ptarticle+amsmath,\showboxof\hbox{$..$}and\hbox{$\displaystyle ..$}. Values are pt; y is positive downward from the baseline. Inline and display are identical.\sideset{_a^b}{_c^d}\sumb/a\sum(cmex10 "58, 14.44447 wide)d/c\sideset{_{ab}^b}{}\sumb,ab\sumx\sideset{}{'}\sum x\sum/ primeOverlap check
gh pr list --state open --search sideset: only math: \sideset attaches script pairs to both sides of a large operator #512 (muse-lead draft, superseded here).TextRunat the same match sites. This branch contains it.\sidesetonce both land. This PR gates it with the existingmissing_packagepath.coord.py claims: GH-SIDESET-GEOMETRY is held by daniel-parent. There are no other sideset/math-layout claims.amsmath-sidesetfeature.Test results
cargo test --test sideset(math-layout):test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered outcargo test(flashtex-math-layout): every targettest result: ok., 0 failed (golden 28, lib 12, size_oracle 2, source_spans 11, big_delimiters 4, kernel_symbols 4, glue_set 5, text_runs 2)cargo test --lib sideset_tests(compiler):test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 339 filtered outcargo test(flashtex-compiler): 56test result: ok.lines, 0 failed, includinghw1_preambleandsupported_latexvendor/compilerandvendor/math-layoutpatched to these commits (this repository'svendor/is untouched):--test amsmath_sideset:test result: ok. 3 passed; 0 failedoracle.py check:TOTAL 59/59 within 0.5 bpNot done
vendor/re-pin before it sets\sideset. The follow-up draft PR carries the conversion and tests behindamsmath-sideset.math::layoutputs the pieces in amsmath's order but has no display operator size. math-layout is the exact engine.\sidesetgroup (amsmath would set it in box 4) is diagnosed and dropped.#3in display style, it becomes a\displaylimitslimit centred on\box4\box6. In amsmath it is centred on the\mathop's wider nominal box (2\wd6-\wd0). That case was not measured.🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz