Skip to content

compiler: longtable, multirow, booktabs extras and colortbl colours in tables - #173

Closed
GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/table-packages-compiler
Closed

GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/table-packages-compiler

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Parses table packages beyond tabular/array into crate::tabular (sources cited inline, TeX Live 2026):

  • longtable v4.24 (only with the package loaded): Tabular::longtable, [l|c|r], \endfirsthead/\endhead/\endfoot/\endlastfoot (Entry::Section), \caption[..]{..}/\caption* (Entry::Caption, table counter stepped per longtable), \kill (Row::kill), \\* (Row::nobreak), \newpage/\pagebreak (Entry::PageBreak); \setlength of \LTleft/\LTright/\LTpre/\LTpost/\LTcapwidth accepted.
  • multirow v2.9: \multirow[vpos]{n}[bigstruts]{width|*|=}[vmove]{text} → Cell::multirow (also inside \multicolumn).
  • booktabs: \cmidrule(l{dimen}r) kerns, \addlinespace, \specialrule, \morecmidrules.
  • colortbl (or xcolor[table]): \rowcolor[m]{c}[l][r], \cellcolor, >{\columncolor}, \arrayrulecolor, \doublerulesepcolor — kept as written (ColorSpec); resolution belongs to the colour model (compiler: color/xcolor with pdfTeX-exact colour operators (982/982 oracle) #150).

New public fields/variants are additive (Row, Cell, ColumnTemplate, Tabular, Entry), so render-pipeline needs a vendor re-pin; the companion render-pipeline PR follows. apps/mac bundled supported-latex.json needs the usual sync.

Tests: cargo test --release all green (lib 256, incl. 4 new parser tests); supported inventory regenerated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…n tables

Parses the table packages beyond tabular/array into the structured table
(crate::tabular), citing the TeX Live 2026 sources:

- longtable.sty v4.24: the environment (only with the package loaded) as a
  paragraph holding one Tabular with `longtable: Some(..)`; `[l|c|r]`;
  `\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot` as Entry::Section
  markers; `\caption[short]{..}`/`\caption*` as Entry::Caption numbered by
  the table counter every longtable steps (text up to the row's `\\`,
  e.g. a `\label`, joins the caption); `\kill` rows (Row::kill); `\\*`
  (Row::nobreak); `\newpage`/`\pagebreak` as Entry::PageBreak;
  `\setlength` of `\LTleft`/`\LTright`/`\LTpre`/`\LTpost`/`\LTcapwidth`
  accepted (read from the source by the pipeline).
- multirow.sty v2.9: `\multirow[vpos]{nrows}[bigstruts]{width|*|=}[vmove]{text}`
  anywhere at the top level of an entry, including inside `\multicolumn`
  (Cell::multirow; the text stays the entry's content).
- booktabs.sty v1.61803398: `\cmidrule(l{<dimen>}r)` explicit trims
  (kern_left_pt/kern_right_pt), `\addlinespace[..]`, `\specialrule{w}{a}{b}`,
  `\morecmidrules`.
- colortbl.sty v1.0k (or xcolor's `table` option): `\rowcolor[m]{c}[l][r]`
  (Row::color; the right overhang copies the left), `\cellcolor[m]{c}`
  (Cell::color), `>{\columncolor[m]{c}[l][r]}` (ColumnTemplate::color),
  `\arrayrulecolor`/`\doublerulesepcolor` before a table (Tabular fields)
  and between rows (Entry::RuleColor/DoubleRuleSepColor). Colours are kept
  as written (ColorSpec model/spec): resolving them is the colour model's
  job (PR #150).

Optional brackets glued to following text (`\rowcolor{x}[1pt][3pt]a`) are
split like `\\[2pt]Next`. The compiler's own layout honours kill rows,
cmidrule kerns, addlinespace, specialrule and captions; colour and page
breaking are the render pipeline's. Supported inventory regenerated
(booktabs, longtable, multirow, colortbl packages; \arrayrulecolor,
\doublerulesepcolor). apps/mac's bundled supported-latex.json needs the
usual sync. cargo test --release: all green (lib 256).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude table packages, 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
booktabs evaluates \cmidrule(l{.5em}) and \addlinespace[1ex] in the font
where the rule is set, whose quad is not the body size (Latin Modern 12pt:
11.75pt). CMidRule::kern_left/kern_right and AddLineSpace::space are now
FontDimen { pt, em, ex }; resolve(em, ex) gives points. Found by tabular
oracle fixture 60 (0.249bp). cargo test --release: all green.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude table packages, 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
GoKubar added a commit that referenced this pull request Sep 13, 2026
…ement and colortbl fills (tabular oracle 59/59 + 18/20 new)

Implements table.rs layout for the compiler fields of #173: kill rows,
booktabs' \@BTrule/\@BTendrule/\@xcmidrule rule classes (specialrule and
addlinespace as class 2, \cmidrulesep after \morecmidrules), explicit
cmidrule kerns, \arrayrulecolor on every rule kind, \doublerulesepcolor
gaps, and colortbl fills per \CT@@Do@color (cell over row over column,
overhangs from \col@sep then column then row). typeset: multirow boxes per
multirow.sty 168-201, fills painted under the entries, colours resolved by
a minimal xcolor stand-in (tablecolor.rs) until #150 lands. The tabular
oracle compares rule and fill colours; fixtures 60-79 with MacTeX 2026
references. Needs vendor/compiler re-pinned to #173. longtable follows.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude table packages, 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
GoKubar added a commit that referenced this pull request Sep 13, 2026
Two facts measured against pdflatex, not derived from the package source:

- `\prevdepth` after a longtable. `\LT@array` builds each chunk in a
  `\vbox` and `\endlongtable`/`\LT@ntabularcr` `\unvbox` it into the
  page's vertical list (longtable.sty 252, 322, 334); `\unvbox` never
  sets `\prevdepth`, so only the boxes the package appends itself —
  `\box\LT@firsthead` (239) and `\box\LT@lastfoot` (506) — do. A table
  with no head and no foot leaves `\prevdepth` as the material before it
  had it. `VBlock::depth_after` says which. Without this the paragraph
  after a headless longtable sat 4.35pt (the `\@arstrutbox` depth) too
  high.
- `\LT@start`'s `\maxdepth\z@` (230) does not reach the page. TeX froze
  `page_max_depth` when the page's first box landed (§987) — before
  `\LT@start` runs for a table that starts mid-page — and `\@makecol`
  ends every page with `\global\maxdepth\@maxdepth`, so continuation
  pages freeze the class value again. Instrumenting `\LT@output` on a
  three-page longtable shows `maxdepth=0pt` only on the first call and
  `6.0pt` after; honouring the zero lost one row per continuation page.
  The page goal is still reduced by `\ht\LT@foot`, which is what decides
  the break.

Corpus: 12 longtable fixtures (80-91) — plain, the four terminators,
two- and three-page breaks with a repeating head and foot, `[l]`/`[r]`,
`\setlength\LTleft`, `\LTpre`/`\LTpost`, `\kill`, `\\*`, booktabs rules
and a wrapping `p{}` column with vertical rules. Their references were
generated on this machine with **TeX Live 2025** (recorded in each
`reference_engine` field), not MacTeX; every committed MacTeX reference
(fixtures 1-79) was checked to be reproduced byte for byte by the local
pdflatex first, and none was rewritten. `oracle.py` now accepts a
fixture with more than one page, which a longtable needs.

Gates on this machine:
- Tabular oracle 91/91 (was 79/79 over 79 fixtures; the 12 new ones all
  pass and none of the old ones changed).
- amsmath corpus 59/59, identical to the main build (bffd168).
- HW1/HW2 rendering-v2 display lists byte-identical to the main build,
  0 errors, 0 overfull.
- `tools/real-world-corpus/run.py --no-oracle --no-pixels`: same status
  and page count on all 9 fixtures; one diagnostic fewer
  (`packages booktabs are recognised but not implemented`, which the
  #173 compiler now implements).
- `cargo test --release` on crates/render-pipeline: 30 test binaries,
  all green.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
`\LT@makecaption` (longtable.sty 475-485) is `\LT@mcol\LT@cols c{\hbox
to\z@{\hss \parbox[t]\LTcapwidth{...}\hss}}`: a row of the alignment like
any other, so it takes the `\@arstrut`, holding a zero-width box centred
on the table, so however wide the caption is it never widens a column.
Inside the parbox the whole caption goes on one centred line when it fits
(`\hbox to\hsize{\hfil\box\@tempboxa\hfil}`) and is set as a paragraph
otherwise, closed by `\endgraf\vskip\baselineskip`. `\parbox[t]` is a
`\vtop`, so `CaptionBox::height` is the first line's height and `depth`
is everything below it, the closing `\baselineskip` included.

`\caption` prefixes `\fnum@table` = `\tablename~\thetable` and a colon;
the tie is a non-breaking space and the space after the colon carries
TeX's space factor (`\sfcode`\:` = 2000), so it takes the face's
`\fontdimen7`. Without that the centred line was 1.3pt narrow and every
word of it sat 0.65bp off. `\caption*` drops the prefix. `\LTcapwidth`
is read from `\setlength`.

The caption of `\endhead` repeats at the top of every continuation page
with the rest of the head; `chunk_geometry` now renumbers a caption's
entry index back to the whole table's, without which the head's caption
was built but never painted.

Corpus: 6 more fixtures (92-97) — a short caption, one wrapping in the
4in parbox, `\caption*`, a first-head and an `\endhead` caption over a
page break, two longtables each stepping the `table` counter, and a
narrowed `\LTcapwidth`. References generated here with TeX Live 2025
(recorded in `reference_engine`); no committed MacTeX reference touched.

Gates on this machine:
- Tabular oracle 97/97 (18/18 longtable, fixtures 1-79 unchanged).
- amsmath corpus 59/59, identical to the main build (bffd168).
- HW1/HW2 rendering-v2 display lists byte-identical to the main build,
  0 errors, 0 overfull.
- Real-world corpus (`--no-oracle --no-pixels`): same status and page
  count on all 9 fixtures; one diagnostic fewer, the booktabs package
  note the #173 compiler resolves.
- `cargo test --release` on crates/render-pipeline: 30 binaries green.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
longtable.sty 135-137 redefines `\newpage` as `\noalign{\break}`, an
eject penalty between rows; the compiler reports it as
`Entry::PageBreak`, which the pipeline now turns into a zero-extent glue
unit carrying `\penalty-\@M` before the next row. The region's foot and
head go in at that break like any other, so the page ends with
`\LT@foot` and the next opens with `\LT@head`.

Fixture 98 (TeX Live 2025 reference, generated here): a two-page
longtable forced by `\newpage` after the third row. Tabular oracle
98/98; HW1/HW2 byte-identical to the main build; `cargo test --release`
on crates/render-pipeline 171 passed, 0 failed.

Also verified on this machine, for the record: PR #173's compiler
(`e84b9885`) builds and its whole suite passes here — 399 tests, 0
failed — with the repository's protocol/, tests/tex-corpus, docs/ and
apps/mac/Fonts alongside it.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 14, 2026
Paused for usage. Converts the compiler's new table fields (PR #173) into
the pipeline's TableItem: row colour/nobreak/kill, cell colour/multirow,
column colour, cmidrule kerns, addlinespace, specialrule, morecmidrules,
rule colours, longtable sections/captions/page breaks, and the `||`
doublerulesep gap as its own material. layout(), typeset's table_box and
the tests are not updated yet, so the crate does not compile against the
re-pinned compiler; it needs vendor/compiler re-pinned to 484cb11 (#173).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude table packages, 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
GoKubar added a commit that referenced this pull request Sep 14, 2026
…ement and colortbl fills (tabular oracle 59/59 + 18/20 new)

Implements table.rs layout for the compiler fields of #173: kill rows,
booktabs' \@BTrule/\@BTendrule/\@xcmidrule rule classes (specialrule and
addlinespace as class 2, \cmidrulesep after \morecmidrules), explicit
cmidrule kerns, \arrayrulecolor on every rule kind, \doublerulesepcolor
gaps, and colortbl fills per \CT@@Do@color (cell over row over column,
overhangs from \col@sep then column then row). typeset: multirow boxes per
multirow.sty 168-201, fills painted under the entries, colours resolved by
a minimal xcolor stand-in (tablecolor.rs) until #150 lands. The tabular
oracle compares rule and fill colours; fixtures 60-79 with MacTeX 2026
references. Needs vendor/compiler re-pinned to #173. longtable follows.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude table packages, 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
GoKubar added a commit that referenced this pull request Sep 14, 2026
Two facts measured against pdflatex, not derived from the package source:

- `\prevdepth` after a longtable. `\LT@array` builds each chunk in a
  `\vbox` and `\endlongtable`/`\LT@ntabularcr` `\unvbox` it into the
  page's vertical list (longtable.sty 252, 322, 334); `\unvbox` never
  sets `\prevdepth`, so only the boxes the package appends itself —
  `\box\LT@firsthead` (239) and `\box\LT@lastfoot` (506) — do. A table
  with no head and no foot leaves `\prevdepth` as the material before it
  had it. `VBlock::depth_after` says which. Without this the paragraph
  after a headless longtable sat 4.35pt (the `\@arstrutbox` depth) too
  high.
- `\LT@start`'s `\maxdepth\z@` (230) does not reach the page. TeX froze
  `page_max_depth` when the page's first box landed (§987) — before
  `\LT@start` runs for a table that starts mid-page — and `\@makecol`
  ends every page with `\global\maxdepth\@maxdepth`, so continuation
  pages freeze the class value again. Instrumenting `\LT@output` on a
  three-page longtable shows `maxdepth=0pt` only on the first call and
  `6.0pt` after; honouring the zero lost one row per continuation page.
  The page goal is still reduced by `\ht\LT@foot`, which is what decides
  the break.

Corpus: 12 longtable fixtures (80-91) — plain, the four terminators,
two- and three-page breaks with a repeating head and foot, `[l]`/`[r]`,
`\setlength\LTleft`, `\LTpre`/`\LTpost`, `\kill`, `\\*`, booktabs rules
and a wrapping `p{}` column with vertical rules. Their references were
generated on this machine with **TeX Live 2025** (recorded in each
`reference_engine` field), not MacTeX; every committed MacTeX reference
(fixtures 1-79) was checked to be reproduced byte for byte by the local
pdflatex first, and none was rewritten. `oracle.py` now accepts a
fixture with more than one page, which a longtable needs.

Gates on this machine:
- Tabular oracle 91/91 (was 79/79 over 79 fixtures; the 12 new ones all
  pass and none of the old ones changed).
- amsmath corpus 59/59, identical to the main build (bffd168).
- HW1/HW2 rendering-v2 display lists byte-identical to the main build,
  0 errors, 0 overfull.
- `tools/real-world-corpus/run.py --no-oracle --no-pixels`: same status
  and page count on all 9 fixtures; one diagnostic fewer
  (`packages booktabs are recognised but not implemented`, which the
  #173 compiler now implements).
- `cargo test --release` on crates/render-pipeline: 30 test binaries,
  all green.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 14, 2026
`\LT@makecaption` (longtable.sty 475-485) is `\LT@mcol\LT@cols c{\hbox
to\z@{\hss \parbox[t]\LTcapwidth{...}\hss}}`: a row of the alignment like
any other, so it takes the `\@arstrut`, holding a zero-width box centred
on the table, so however wide the caption is it never widens a column.
Inside the parbox the whole caption goes on one centred line when it fits
(`\hbox to\hsize{\hfil\box\@tempboxa\hfil}`) and is set as a paragraph
otherwise, closed by `\endgraf\vskip\baselineskip`. `\parbox[t]` is a
`\vtop`, so `CaptionBox::height` is the first line's height and `depth`
is everything below it, the closing `\baselineskip` included.

`\caption` prefixes `\fnum@table` = `\tablename~\thetable` and a colon;
the tie is a non-breaking space and the space after the colon carries
TeX's space factor (`\sfcode`\:` = 2000), so it takes the face's
`\fontdimen7`. Without that the centred line was 1.3pt narrow and every
word of it sat 0.65bp off. `\caption*` drops the prefix. `\LTcapwidth`
is read from `\setlength`.

The caption of `\endhead` repeats at the top of every continuation page
with the rest of the head; `chunk_geometry` now renumbers a caption's
entry index back to the whole table's, without which the head's caption
was built but never painted.

Corpus: 6 more fixtures (92-97) — a short caption, one wrapping in the
4in parbox, `\caption*`, a first-head and an `\endhead` caption over a
page break, two longtables each stepping the `table` counter, and a
narrowed `\LTcapwidth`. References generated here with TeX Live 2025
(recorded in `reference_engine`); no committed MacTeX reference touched.

Gates on this machine:
- Tabular oracle 97/97 (18/18 longtable, fixtures 1-79 unchanged).
- amsmath corpus 59/59, identical to the main build (bffd168).
- HW1/HW2 rendering-v2 display lists byte-identical to the main build,
  0 errors, 0 overfull.
- Real-world corpus (`--no-oracle --no-pixels`): same status and page
  count on all 9 fixtures; one diagnostic fewer, the booktabs package
  note the #173 compiler resolves.
- `cargo test --release` on crates/render-pipeline: 30 binaries green.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 14, 2026
longtable.sty 135-137 redefines `\newpage` as `\noalign{\break}`, an
eject penalty between rows; the compiler reports it as
`Entry::PageBreak`, which the pipeline now turns into a zero-extent glue
unit carrying `\penalty-\@M` before the next row. The region's foot and
head go in at that break like any other, so the page ends with
`\LT@foot` and the next opens with `\LT@head`.

Fixture 98 (TeX Live 2025 reference, generated here): a two-page
longtable forced by `\newpage` after the third row. Tabular oracle
98/98; HW1/HW2 byte-identical to the main build; `cargo test --release`
on crates/render-pipeline 171 passed, 0 failed.

Also verified on this machine, for the record: PR #173's compiler
(`e84b9885`) builds and its whole suite passes here — 399 tests, 0
failed — with the repository's protocol/, tests/tex-corpus, docs/ and
apps/mac/Fonts alongside it.

Implementation-Agent: claude-opus-5 (table-packages lane, nixos linux-primary)
Commit-Executor: claude-opus-5

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 14, 2026
…iler

compiler: longtable, multirow, booktabs extras and colortbl colours in tables (rebase of #173 onto current main)
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: 5baa9e6 (PR #250)

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/table-packages-compiler branch September 16, 2026 04:18
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