Repository navigation
compiler: skip the [t]/[b]/[c] position argument of nested grids (#115 split, part 1) - #124
Merged
Merged
Conversation
The box-position argument of array/aligned/alignedat/gathered (latex.ltx \@array, amsmath \ams@start@box) comes before the preamble and is not a cell. It was parsed into the first cell as `[`, `t`, `]`. The parser now skips it; the render pipeline reads the letter from the source at \begin. amsmath oracle corpus: 17 new fixtures (43-59) of grids nested inside fractions, radicands, scripts, \overset, \left...\right bodies and other grids' cells, refs from pdfTeX (TeX Live 2026). Compiler-side split of #115 (source commit 4d884b3), rebased on main 1d4604d. The render-pipeline half is a separate stacked PR that needs vendor/compiler re-pinned to this commit. compiler cargo test --release green, including the supported_latex drift gate (no regeneration needed: the supported inventory is unchanged). Implementation-Agent: Claude Opus 5 (subagent kabir-claude rebase 114/115, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Member
|
Merged to main via integration/2026-09-13j (Commander). |
This was referenced Sep 13, 2026
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
… a space
The gap between a theorem-like head and its body was an interword space read
from the source newline after `\begin{...}` — and because the head ends in
`.`, a *sentence* space (`4.83948 plus 5.44014 minus 0.40297` at 11pt).
amsthm puts its own glue there and then `\ignorespaces`.
Measured against pdflatex (TeX Live 2025, oracle only, never in the product
path), `\documentclass[11pt]{article}` + `[T1]{fontenc}` + amsthm with
`\tracingoutput=1`:
* a `\newtheorem` environment's head ends with `\hskip\thm@headsep`
(amsthm.sty `\@begintheorem`), `\thm@headsep = 5\p@ plus\p@ minus\p@`.
The shipped page: `\T1/cmr/bx/n/10.95 .`, `\glue 5.0 plus 1.0 minus 1.0`,
then the body. It is absolute — the same 5pt at 10, 11 and 12pt — and it
stretches, which a sentence space's five-times-larger stretch does not
reproduce on a line that is set loose;
* `proof` is not a `\newtheorem` style but a plain `\trivlist` `\item
[\hskip\labelsep \itshape #1\@addpunct{.}]`, so the glue after its label
is the `\hskip\labelsep` `\@item` appends after the label box, rigid:
`\hbox(7.60416+2.12917)x67.05003` then `\glue 5.475` then `\penalty 0`.
`\showthe\labelsep` prints 5.0pt / 5.475pt / 5.87494pt at 10 / 11 / 12pt,
which is what `flashtex_document_style::list_level` already resolves.
New `src/amsthm.rs` recognises the head from the compiler's own output
rather than from a `\newtheorem` scan: `parser::begin_theorem`/`begin_proof`
are the only places that give a synthesised `Inline::Text` the span of a
`\begin` control word. It returns the glue and the byte the head ends at
(past `{<env>}` and any `[<note>]`); `items_from_inlines_styled` emits that
glue in place of the gap before the first inline at or after it, so the
source's own whitespace is dropped exactly as `\ignorespaces` drops it —
`\begin{theorem}Body`, `\begin{theorem}\n Body` and
`\begin{theorem}\label{k}\n Body` all give the same head (`\label`'s
`\@esphack` takes the glue off and puts it back with `\ignorespaces`).
`Item::HSpace` grows `stretch_pt`/`shrink_pt` and becomes `Glue::finite`
rather than `Glue::fixed`; `\hspace` keeps passing 0/0 and is unchanged.
## Gates
NixOS host, bundled `apps/mac/Fonts` with the explicit `FLASHTEX_TFM_DIRS`
spelling that reaches the rooted metrics reader; never the system TeX Live.
Real-world corpus, v2 display lists against an `origin/main` control: nine of
ten fixtures **byte-identical** (hw1, hw2, cv, inline-math,
input-bibliography, letter, math-sheet, unicode-accents, article-twocolumn),
`lecture-notes` the only one that moves. Its diagnostics are byte-identical
too (8, none of them a font substitution, 0 overfull); every status and page
count unchanged.
`lecture-notes` word geometry against the committed `reference.pdf`
(difflib-aligned words, |dx| in bp). The head is only *exact* with all three
parts in place, and the errors partly cancel, so every combination is
measured:
| build | median |dx| | ≤0.01 bp | ≤0.1 bp | ≤0.5 bp | lines |
|---|---|---|---|---|---|
| `main` | 7.6051 | 116 | 125 | 138 | 32/56 |
| + this PR | 7.2493 | 116 | 125 | 138 | 32/56 |
| + #190 | 0.1366 | 174 | 199 | 285 | 38/56 |
| + #190 + this PR | 0.0305 | 199 | 245 | 340 | 38/56 |
| + #190 + this PR + the compiler PR | **0.0048** | **235** | **284** | 339 | 38/56 |
No line is lost in any combination, and the 419 aligned words and the
`max |dx|` (112.737 bp, the pre-existing math-run/extraction outliers) are
the same throughout.
On the fixture's own `Definition 3.1.` line, body start against the oracle's
155.3717 bp: `main` + #190 155.8772 (+0.5055), with this PR 154.9534
(−0.4183), with the compiler PR as well **155.3744 (+0.0027)** — and the
whole rest of that line then lands inside 0.06 bp.
`cargo test --release --no-fail-fast` on `crates/render-pipeline`, with the
font environment: see the PR description for the failing-set comparison
against an `origin/main` control of the same base.
Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer (Claude Opus 5), direct git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
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.
Compiler-side half of #115, split out as the Commander asked on #2 (no vendor edits in feature PRs). Base: main 1d4604d. Commit: 59e5042, taken from #115's source commit 4d884b3.
What
crates/compiler/src/math.rs: the box-position argument ofarray/aligned/alignedat/gathered([t],[b],[c]) comes before the preamble (latex.ltx\@array, amsmath\ams@start@box).[,t,].grid_position_argument_is_not_a_cellcovers it.\overset,\left…\rightbodies and other grids' cells.crates/math-layoutchanges. No vendor changes.Gates (mac-m5pro-kabir)
cargo test --release: green, every test binary ok.supported_latexdrift gate (8 passed). No regeneration was needed, because the supported inventory is unchanged.crates/render-pipeline/vendor/compilerre-pinned to this commit.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu