Skip to content

render-pipeline: lay tabular out with the kernel alignment model (tabular corpus 1/54 -> 45/54) - #116

Merged
jay3332 merged 2 commits into
mainfrom
agent/kabir-claude/tabular-fidelity
Sep 13, 2026
Merged

jay3332 merged 2 commits into
mainfrom
agent/kabir-claude/tabular-fidelity

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What

Before this PR the render pipeline (the product path) flattened every tabular to its cells' text with an unsupported_block warning. Tables are now laid out as one box in the paragraph, using the LaTeX kernel's alignment model plus booktabs (crates/render-pipeline/src/table.rs, citing latex.ltx 2026 and booktabs.sty line by line):

  • Columns: \halign column widths, with \multicolumn excess pushed into the last spanned column (TeX §801); columns with no entries are zero-width.
  • Lengths and rules: \tabcolsep, \arrayrulewidth and \doublerulesep come from \setlength. | rules take no width, are centred on their boundary and run the full row; || is separated by \doublerulesep.
  • Rows: \@arstrut is the \strutbox of the size in force (size1x.clo) times \arraystretch. \\[d] works for positive and negative d; \hline, \hline\hline and \cline are supported.
  • p{}: set as a \vtop under \@arrayparboxrestore/\sloppy, with \@finalstrut.
  • Width and position: tabular* distributes leftover width through \extracolsep{\fill}. [t]/[b]/[c] use \vtop/\vbox/\vcenter on the math axis.
  • booktabs: top/mid/bottom rules and \cmidrule(lr) at the body font's em/ex.
  • Implementation: cells are shaped by the existing TFM paragraph path and painted as nested blocks plus display-list rules. Blocks that contain a table are not cached.

No compiler source changes. vendor/compiler is main's pin (ad720575, byte-identical to crates/compiler/src), so no re-pin is needed.

Evidence

The oracle corpus crates/compiler/tests/tabular_corpus/ has 54 one-page 12pt fixtures and an oracle.py that reads pdflatex word origins plus rule rectangles from the PDF content stream. A fixture passes when every word is within 0.5 bp and every rule within 0.1 bp.

group main 3f7fd9b this PR
l/c/r, |, ||, @{} (01-09) 0/9 9/9
p{} (10-12, 52) 0/4 2/4
\multicolumn (13-16) 0/4 4/4
\hline, \cline (17-20) 0/4 4/4
\arraystretch, \tabcolsep, \[len] (21-26) 0/6 6/6
tabular*, [t]/[b]/[c], nested (27-32) 0/6 6/6
math array (33-34) 1/2 1/2
booktabs (35-39) 0/5 4/5
array package (40-44) 0/5 0/5
empty/math/styled cells, rule lengths, \small, center, two tables (45-51, 53-54) 0/9 9/9
total 1/54 45/54
  • cargo test --release is green for crates/compiler and crates/render-pipeline. The new tests/tabular_oracle.rs pins the 45 passing fixtures, and table.rs has font-free geometry unit tests.
  • Real-world corpus (like-for-like archive builds): HW1, HW2, lecture-notes, math-sheet, letter, input-bibliography, unicode-accents and article-twocolumn are byte-identical. cv (tabular*) changes; aligned words and errors are unchanged.

Not fixed here (owners)

  • p{} breaking (11, 52): paragraph-layout's badness() returns infinity above a stretch ratio of 1.29. TeX §108 only does so above 1290/297 ≈ 4.34. Under \sloppy (tolerance 9999), TeX's loose lines are therefore infeasible, and the emergency pass sets them under-width.
  • booktabs-article (39): text-mode \, reaches the pipeline as a literal comma (compiler text pass).
  • array package (40-44): >{}/<{}, m/b, !{} and \extrarowheight are diagnosed as unsupported by the parser.
  • math array inline (33): math grid layout.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 13, 2026 06:10
Tables were flattened to their cells' text (unsupported_block). table.rs now lays the compiler's parsed tabular/tabular* out as one box in the paragraph: \halign column widths with \multicolumn excess in the last spanned column (TeX 801), \tabcolsep/\arrayrulewidth/\doublerulesep (read from \setlength), zero-width centred | rules, \@arstrut from the size's \strutbox times \arraystretch, \\[d], \hline/\hline\hline/\cline, p{} as \vtop with \@finalstrut, tabular* \extracolsep{\fill}, [t]/[b]/[c], booktabs rules at the body font's em/ex. Cells are shaped by the pipeline's TFM paragraph path and painted as nested blocks plus display-list rules; blocks holding a table are not cached.

Oracle corpus crates/compiler/tests/tabular_corpus (54 fixtures, pdflatex word and rule positions): main 1/54, this branch 45/54. tests/tabular_oracle.rs pins the 45.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude tabular fidelity, 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
…ults

Implementation-Agent: Claude Opus 5 (subagent kabir-claude tabular fidelity, 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
@jay3332
jay3332 merged commit 1d4604d into main Sep 13, 2026
11 of 18 checks passed
@jay3332

jay3332 commented Sep 13, 2026

Copy link
Copy Markdown
Member

Merged to main via integration/2026-09-13h (Commander).

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.

2 participants