Skip to content

compiler: siunitx S[...] and s table columns (#324) - #331

Merged
GoKubar merged 1 commit into
mainfrom
agent/daniel-vpclaude/siunitx-s-columns
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/daniel-vpclaude/siunitx-s-columns

Conversation

@d-q222

@d-q222 d-q222 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #324 (phase 1). Claim GH-324, daniel-vpclaude (Claude Pro).

Problem: \begin{tabular}{l S[table-format=1.3]} was read one character at a time. S, [, and every letter of table-format=1.3 each reported illegal character 'X' in the column specification, about 85 errors across fixtures/real-world/siunitx-tables and lab-report.

Change (crates/compiler/src/parser/tabular.rs):

  • Array package: siunitx loads array.sty (\RequirePackage{array}, siunitx.sty v3.4.14 line 9321), so siunitx joins ARRAY_PACKAGES.
  • Column spec: with siunitx loaded, S[<options>]/s[<options>] is one SpecItem::Siunitx, a centred column (\@classz). A \newcolumntype{S} still wins, and without siunitx S is still an illegal character.
  • Entries: a plain entry holding a digit in an S column (words plus \pm/\mp/\times/\cdot) is typeset as \num[<options>]{…}, and a plain s entry as \unit. The synthesized tokens carry the entry's own spans.
    • table-* keys are layout keys and are dropped before \num. Other keys reach the formatter, which warns as usual if a key isn't implemented.
    • Braced ({Batch}), blank and command-bearing entries stay text.
  • Not implemented: alignment on the decimal marker. This is reported honestly as one warning per specification: "siunitx S columns align numbers on the decimal marker, which is not implemented".

Evidence:

  • Fixtures (current crates/compiler, JSON protocol): siunitx-tables and lab-report both have 0 column-spec errors, down from about 85 across the two on main. What remains is unrelated: table/\caption float errors and the fixture's deliberately empty \si{} and \SI{} prose.
  • New tests: tests/siunitx_columns.rs has 5 tests. 4 fail without the fix; the no-siunitx control passes either way.
  • Suite: the full compiler suite was green on the first revision. A rerun on the final commit, which only moves the spans of the inserted tokens, is in progress and will be reported in a comment. Only my own hunks are rustfmt-clean; main already has 21 existing drifts in this file.
  • Inventory: the tabular supported-LaTeX description is updated and regenerated. The Mac supported-latex.json copy is synced; it had been stale since render-pipeline: longtable, multirow, cmidrule trims and colortbl fills (rebase of #176 onto current main; + the gate that was not measuring them) #251 (colortbl/booktabs/longtable/multirow rows).

Integration: this is compiler-only, so it reaches the app and CLI at the next vendor re-pin. It doesn't touch vendor/.

Phase 2, not in this PR: table-format widths and decimal alignment in layout.

🤖 Generated with Claude Code

https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ

siunitx loads array.sty (siunitx.sty 9321), so it joins ARRAY_PACKAGES.
With siunitx loaded, S[<options>] and s[<options>] are read as one column
specification item instead of one illegal character per letter. Both are
centred columns; plain numeric S entries are typeset through \num with the
column's options (table-* layout keys dropped) and plain s entries through
\unit. Braced, blank and command-bearing entries stay text, as siunitx sets
{...} entries. Decimal-marker alignment is not implemented and is reported
once per specification.

Clears every column-specification error in fixtures/real-world
siunitx-tables and lab-report. Syncs the Mac supported-latex.json copy,
which was stale since #251.

Refs #324

Implementation-Agent: daniel-vpclaude (Claude Code, Claude Pro)
Commit-Executor: daniel-vpclaude (direct git)
Co-authored-by: d-q222 <[email protected]>
Claude-Session: https://claude.ai/code/session_012iWhnaQddU1UTMh6ZssGBJ
@d-q222

d-q222 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Suite rerun on the final commit 821eb8a: full crates/compiler suite green (30 test binaries ok, 0 FAILED), and siunitx_columns 5/5 and supported_latex 8/8 pass. — daniel-vpclaude

@GoKubar
GoKubar merged commit e44d591 into main Sep 14, 2026
18 of 20 checks passed
@GoKubar
GoKubar deleted the agent/daniel-vpclaude/siunitx-s-columns branch September 14, 2026 14:49
GoKubar added a commit that referenced this pull request Sep 14, 2026
`main` advanced by 16 commits while the first re-pin was being measured, five
of them in `crates/compiler`, so `c1ae760d` was already stale. Re-exported at
`e44d5917`, which also carries #339 (`\langle`/`\rangle` as U+27E8/U+27E9
mathopen/mathclose -- the corpus's `twelvept-plain` fixture was reporting "no
math glyph for '<'" and drawing an empty box), #321 (`\pagestyle`,
`\thispagestyle`, `\pagenumbering` in the preamble), #244 (`\maketitle`
without `\author`), #314 (`\odot`/`\ominus`/`\oslash`/`\bigcirc` as binary
operators) and #331 (siunitx `S[...]`/`s` columns) on top of #380's natbib.

Byte-identity re-verified at the new SHA the same two ways: the vendored
tree's path/mode/blob-SHA listing matches `git ls-tree -r
e44d591:crates/compiler` on all 555 files, and `diff -r --exclude=PIN`
against a fresh re-extraction is empty.

The no-other-directory-needs-re-pinning finding was re-checked against the new
`main` rather than carried over: `math-layout`, `paragraph-layout`,
`microtype`, `document-style`, `font-resources`, `tex-text-encoding`,
`tex-boxes`, `tex-expansion` and `vector-graphics` are still byte-identical to
`main`'s crates, and `font-engine`/`pdf`/`project-files` still differ only by
their own rows' deliberate choices.

Gates re-run at this pin, same font environment:

  cargo test --release on crates/render-pipeline   254 passed, 0 failed, 2 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document; the only diagnostics
remain `math_resource_profile` (4 on HW1, 7 on HW2), which are informational.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking) is still OPEN and so
is still deliberately absent from this pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
GoKubar added a commit that referenced this pull request Sep 14, 2026
… natbib (#386)

* render-pipeline: re-pin vendor/compiler to main so the corpus can see natbib

`crates/render-pipeline/vendor/*` are frozen `git archive` snapshots, so a
compiler-side change is invisible to `flashtex-render` -- and therefore to the
whole rendered corpus -- until the pin moves. `vendor/compiler` sat at
`f9bab2a7` (PR #267), one `crates/compiler` commit behind: PR #380
(`dd4a9809`, natbib citations and the `\bibitem[Author(Year)]` labels behind
them). #381 had already landed the render-pipeline half against the live
crate, so the corpus's `natbib-review` fixture was being measured against a
pipeline whose vendored compiler still could not parse `\citep`/`\citet`.

Re-exported from `main` at `c1ae760d`:

    git archive c1ae760:crates/compiler | tar -x -C vendor/compiler
    git rev-parse c1ae760 > vendor/compiler/PIN

Byte-identity verified two independent ways: a path/mode/blob-SHA listing of
the vendored tree matches `git ls-tree -r c1ae760:crates/compiler` on all 553
files, and `diff -r --exclude=PIN` against a fresh re-extraction is empty.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking -- the rebase of the
closed #379) was still OPEN when this pin was taken, so it is deliberately not
carried here: a vendor pin never holds an unmerged branch. It will arrive with
the next re-pin after it merges.

No other vendor directory needed re-pinning, and this was checked rather than
assumed. `crates/compiler`'s own path dependencies at `c1ae760d` are
`font-engine`, `tex-text-encoding`, `tex-boxes` and `tex-expansion`; a
recursive diff of every vendor directory against `main`'s crate of the same
name shows `math-layout`, `paragraph-layout`, `microtype`, `document-style`,
`font-resources`, `tex-text-encoding`, `tex-boxes` and `tex-expansion` already
byte-identical to `main`. `font-engine`, `pdf` and `project-files` do differ,
but each by its own VENDORING.md row's deliberate choice, and none of those
deltas is an API the new compiler needs -- the build and the full test run
below confirm it.

Also noted in the VENDORING.md row: that table's `compiler` and `math-layout`
cells still name `ea4ee5c8`, while the `PIN` files held `f9bab2a7` and
`9a82257b`. The table had drifted behind `PIN`; `PIN` is the authority. Only
the `compiler` row is corrected here, and by prepending -- the old log text is
kept intact.

Gates, all with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to
`apps/mac/Fonts` and its lm + jknappen/ec + amsfonts/symbols TFM trees:

  cargo test --release on crates/render-pipeline   249 passed, 0 failed, 1 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document. The only diagnostics are
`math_resource_profile` (4 on HW1, 7 on HW2), which report that Latin Modern
Math supplies one 10 pt design for several optical sizes -- informational, not
a failure, and unchanged by this re-pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>

* render-pipeline: move the vendor/compiler pin forward to current main

`main` advanced by 16 commits while the first re-pin was being measured, five
of them in `crates/compiler`, so `c1ae760d` was already stale. Re-exported at
`e44d5917`, which also carries #339 (`\langle`/`\rangle` as U+27E8/U+27E9
mathopen/mathclose -- the corpus's `twelvept-plain` fixture was reporting "no
math glyph for '<'" and drawing an empty box), #321 (`\pagestyle`,
`\thispagestyle`, `\pagenumbering` in the preamble), #244 (`\maketitle`
without `\author`), #314 (`\odot`/`\ominus`/`\oslash`/`\bigcirc` as binary
operators) and #331 (siunitx `S[...]`/`s` columns) on top of #380's natbib.

Byte-identity re-verified at the new SHA the same two ways: the vendored
tree's path/mode/blob-SHA listing matches `git ls-tree -r
e44d591:crates/compiler` on all 555 files, and `diff -r --exclude=PIN`
against a fresh re-extraction is empty.

The no-other-directory-needs-re-pinning finding was re-checked against the new
`main` rather than carried over: `math-layout`, `paragraph-layout`,
`microtype`, `document-style`, `font-resources`, `tex-text-encoding`,
`tex-boxes`, `tex-expansion` and `vector-graphics` are still byte-identical to
`main`'s crates, and `font-engine`/`pdf`/`project-files` still differ only by
their own rows' deliberate choices.

Gates re-run at this pin, same font environment:

  cargo test --release on crates/render-pipeline   254 passed, 0 failed, 2 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document; the only diagnostics
remain `math_resource_profile` (4 on HW1, 7 on HW2), which are informational.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking) is still OPEN and so
is still deliberately absent from this pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
GoKubar added a commit that referenced this pull request Sep 14, 2026
)

The two halves of this tool disagreed about what a word is. `pdftext.py`
built reference words from glyphs — breaking on a space, a new baseline, a
new text object or a gap wider than 0.16 em, and explicitly *not* on a font
change. `rank.py` built candidate words from `glyph_run` items, splitting
only on space clusters *within* a run and never joining across runs. But a
`glyph_run` is a typesetting artefact, not a word: the pipeline starts a new
run at every face change.

So one siunitx `S` cell arrived as three candidate words (`1`, `.`, `234`)
against the reference's one (`1.234`) — because pdfTeX sets that cell as
three `Tf`-switched runs inside one text object, and the reference's rule
joins them. `difflib` then aligned the two sequences against each other and
reported the disagreement as geometry.

That is what made PR #331 (siunitx `S`/`s` columns) read as a regression it
was not: `lab-report` page 2 went from 78 to 118 candidate words and 70 to
50 aligned, with the ink unchanged and correctly placed. Feeding the
candidate's glyphs through `pdftext.words_from_glyphs` removes the
disagreement by construction — there is now one definition of a word in this
tool, in one function, used by both sides.

`words_from_glyphs` gains `glyph_index`; a word's glyphs are always
contiguous in its input, so `rank.py` carries `math` and the source span
across the grouping without the grouper having to know about them. The
reference path is otherwise untouched.

Measured on all 22 real-world fixtures with one producer binary
(`31b84428`), harness the only variable:

  aligned words   14135 -> 15040   (+905, +6.4%)
  dx              85.89% -> 85.33%
  dy              76.07% -> 75.08%
  both            70.03% -> 69.02%
  page counts     22/22 unchanged

The percentages fall while the measurement gets better, and both facts are
real. 905 more words now pair up, and they are disproportionately the hard
ones — math and table material that previously could not align at all and
so sat outside the denominator. Coverage rises, the average over a harder
population falls. Sixteen fixtures gain aligned words, four are unchanged,
two lose a handful. The two siunitx fixtures, which triggered this, land
exactly on the reference:

  lab-report p2      cand 118 -> 70  (ref 71), aligned 50 -> 70
  siunitx-tables p1  cand 388 -> 353 (ref 353), aligned 322 -> 345
  siunitx-tables p2  cand 297 -> 275 (ref 275), aligned 257 -> 272

`lab-report` p2's worst delta drops from 91.75 bp to 0.01 bp.

It also stops hiding stray ink, which is why `unicode-accents` loses one
aligned word. That fixture has a run, `ellipsis\dots;`, whose last five
glyphs sit at **x = -12321 bp** — about 12.3k bp left of the page. Grouping
by run put all ten glyphs in one word whose `x` came from the first glyph,
so the tool reported it as fine. Grouping geometrically splits at the
backwards jump and the fragment keeps its own origin, and
`unicode-accents` page 1 is now the corpus's top-ranked item at
dx -12640.53. The defect is in the producer's display list, is present on
`main` independently of this change (same bytes in both runs), and is not
touched here — this commit only stops concealing it.

`python3 -m unittest discover -s tools/visual-oracle -p 'test_*.py'`:
13 passed (was 8). A full `rank.py` run over the three affected fixtures
produces its report unchanged in shape.

Implementation-Agent: Claude Opus 5 (lane nixos-graphics-sectioning, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
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.

compiler: siunitx S[...] table columns are parsed character by character (≈85 errors)

2 participants