Skip to content

render-pipeline: longtable regions through footnote and float pagination (rebase of #184 onto current main) - #253

Merged
GoKubar merged 3 commits into
mainfrom
rebase/184-longtable-inserts
Sep 14, 2026
Merged

GoKubar merged 3 commits into
mainfrom
rebase/184-longtable-inserts

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Rebase of #184 (agent/kabir-claude/longtable-inserts) onto current main, on top of #251. Supersedes #184 — its branch is untouched.

longtable regions through the footnote page builder and float pagination, \LTchunksize scoped out, plus the three longtable fixes that scoping found. Base chain: #250 (compiler) → #251 (pipeline) → this.

All three commits cherry-picked cleanly onto the rebased #251; the integration work was all in #251.

Gates, measured on this tree

Control is main @ 5e6c65be with its own committed vendor pin; this branch was measured with vendor/compiler locally re-pinned to #250 (not committed — vendor is the integration lane's).

gate control #251 this branch
tabular corpus (oracle.py check) 59/59 98/98 106/106
tabular corpus (cargo test --test tabular_oracle) 53 of 59 asserted 98/98 106/106 asserted
font diagnostics over the corpus 0 0 0
amsmath corpus 59/59 59/59 59/59
crates/render-pipeline cargo test --release 213 passed, 0 failed 219, 0 failed 219 passed, 0 failed
real-world corpus, HW1 render 3 pages, 0 errors, 0 overfull — 3 pages, 0 errors, 0 overfull
real-world corpus, HW2 render 3 pages, 0 errors, 0 overfull — 3 pages, 0 errors, 0 overfull
real-world corpus, all 10 fixtures — — page counts identical; one diagnostic fewer

106/106 is now asserted by cargo test, not only by the corpus's own oracle.py — see #251 for why that was not previously true.

Fonts throughout: FLASHTEX_FONT_DIRS=apps/mac/Fonts, FLASHTEX_TFM_DIRS at its lm/jknappen/ec/amsfonts/symbols metrics. No committed oracle data was regenerated.


Rebased and re-measured against main 5e6c65be. main moved 53 commits during this work, including changes to parser.rs, typeset.rs and mathtex.rs; every number in this PR is from the final tree, not the earlier base.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 3 commits September 13, 2026 22:22
`break_pages_inserts` now takes the same `ResolvedRegion`s that
`break_pages_regions` does, so a longtable on a page with footnotes keeps
`\endhead`/`\endfoot` across a break. `\pagegoal` carries both charges at
once: `\LT@start` takes `\ht\LT@foot` off it (longtable.sty 229) and TeX's
insertion machinery takes `\skip\footins` and the notes (§1009), so a note
and a continuation foot compete for the same page; the insertion's own
fit-or-split test (§1010) sees the reserved foot too.

Two behaviours the no-footnote path never needed, both measured against
pdflatex on the new fixtures:

- longtable.sty 223 ends `\LT@start` with
  `\ifdim\pageshrink>\z@\pageshrink\z@\fi`: the glue already on the page
  (`\parskip`, `\LTpre`'s own `minus 4pt`, `\skip\footins`'s `minus 2pt`)
  may no longer be shrunk to buy the table one more row. Without it the
  builder squeezed r41 onto the first page of 99-longtable-footnote where
  pdflatex stops at r40, and then `\@makecol` shrank `\LTpre` by 1.98 bp to
  pay for it, lifting the whole table.
- `\LT@output` builds `\box\@cclv` as `\vbox{\unvbox\@cclv \copy\LT@foot
  \vss}` and only then calls `\@makecol` (487-517), so the `\vss` sits
  inside the body ahead of `\skip\footins`. It takes the column's whole
  slack and pushes the note block to the foot of the page, leaving every
  finite glue natural. Without it the footnote rule sat 11.49 bp too high.

The head and foot are materialised as vertical-list items of the page's
body rather than appended afterwards, which is what puts them through
`\@makecol`'s natural-size and glue-setting passes with the rest.

The `table_limitation` diagnostic for footnotes is gone; the float one
stays.

Gate: tabular oracle 101/101 with the bundled symlink-free font tree
(`apps/mac/Fonts` plus its three TFM directories), zero
font_unavailable/required_metrics_unavailable/ec_metrics_unavailable
diagnostics on every fixture. Fixtures 1-98 unchanged.

New fixtures (references from local TeX Live 2025, recorded in
`reference_engine`):
- 99-longtable-footnote: two-page table, note on the page the table starts
  and breaks on.
- 100-longtable-footnote-after: note on the page the table ends on.
- 101-longtable-footnotes-three-pages: notes on the first and last of
  three pages, so a continuation page carries head, rows and foot between
  two note-bearing pages.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
`floatpage::paginate` takes the same `ResolvedRegion`s as the other two
page builders, so a longtable in a document with floats keeps
`\endhead`/`\endfoot` across a break. Inside a region the column goal
loses `\ht\LT@foot` and `\pageshrink` is zero (longtable.sty 229, 223);
a break inside one ends the page with `\LT@foot` and opens the next with
`\copy\LT@head`. A node the float machinery spliced in reports the list
index of the last real item, so `\@specialoutput`'s own penalties are
charged inside the region like any other.

One behaviour only this path has, measured against pdflatex on
103-longtable-float-deferred: `\LT@output` runs `\@makecol\@outputpage
\global\vsize\@colroom \copy\LT@head` and never `\@opcol`/`\@startcolumn`
(longtable.sty 513-516), so a page that continues a longtable gets no
float page tried and no deferred float added — the whole column is the
table's. With three `[t]` figures ahead of a two-page table, `topnumber`
keeps the third off page 1 and pdflatex does not put it at the top of
page 2 either; it stays deferred until `\end{document}`'s `\clearpage`
sets it on a float page of its own. Without `start_longtable_column` it
landed on page 2 and pushed the continuation head down 40.45 bp.

longtable.sty 489-491 makes a float or marginpar *inside* the table a
LaTeX error; that is now a targeted `table_limitation` naming the float,
and the blanket "in a document with floats" diagnostic is gone.

Gate: tabular oracle 103/103 with the bundled symlink-free font tree,
zero font/metric fallback diagnostics on every fixture. Fixtures 1-101
unchanged. `cargo test --release` (no `FLASHTEX_*` in the environment):
171 passed, 0 failed, `floats_oracle` included.

New fixtures (references from local TeX Live 2025):
- 102-longtable-float-top: a `[t]` figure above a two-page table.
- 103-longtable-float-deferred: three `[t]` figures, the third deferred
  past the continuation page onto a float page.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…t found

`\LTchunksize` (longtable.sty 65, default 200) is deliberately not
modelled, with the reason and the measurements in `longtable.rs`. Chunking
only ever narrows a chunk to the widest cell *seen so far*; longtable
writes the final widths to the `.aux` (253-259) and warns `Column widths
have changed`, so the next run sets every chunk at the maximum — which is
what measuring the whole table once already produces. Verified on two
shapes: 260 rows with the widest cell past the default 200-row boundary,
and 30 rows with `\LTchunksize=5` and the widest cell in the sixth chunk.
Both warn on pass 1, are silent on pass 2, and their two-pass references
match this module's single measurement exactly. Modelling chunking would
only reproduce the unconverged first pass.

Building those two fixtures turned up three real mismatches, all measured
against pdflatex:

- **`\maxdepth\z@` does reach the page a table opens.** `\LT@start` sets
  it (longtable.sty 230) on the outer vertical list after `\LT@echunk` has
  closed the first chunk but before `\unvbox\z@` contributes any row, so
  §987 `freeze_page_specs` copies the zero into `page_max_depth` exactly
  when the table's first row is also the page's first box. A table under
  existing material finds it already frozen at `\@maxdepth`, and every
  later page of the table gets `\@maxdepth` back from `\@makecol`, so only
  the page a table *opens* is affected — which is why the earlier
  fixtures, all of which have a paragraph above the table, never saw it.
  104-longtable-chunk-boundary begins with the table and loses one row on
  its first page.

- **`\copy\LT@head`, not `\box`.** Without `\endfirsthead` the opening
  head *is* `\LT@head` (239), and without `\endlastfoot` the closing foot
  *is* `\LT@foot` (506), so the same cells are set twice. The piece
  builder removed each cell's block from the map, so the second use — the
  box the output routine repeats — kept its rules and lost its text. The
  repeated head and foot of every table written with only `\endhead` and
  `\endfoot`, a very common shape, were blank.

- **The closing foot does not set `\prevdepth`.** `\box\ifvoid\LT@lastfoot
  \LT@foot\else\LT@lastfoot\fi` is inside `\LT@output` (506), and the
  output routine builds its own vertical list (§1025 `push_nest`) whose
  `prev_depth` §1026 discards when it hands the material back to the
  contribution list. Only `\LT@start`'s opening head runs on the outer
  list, so that is what the table leaves behind; with no head at all the
  value is unchanged, as this lane's predecessor measured. A probe with
  the same table after a paragraph with and without a descender puts the
  following paragraph at the same distance both times, so the value is
  fixed rather than inherited, and 4.34 pt below where `\dp\LT@foot` would
  put it. The earlier fixtures all end in `\hline\hline`, whose depth is
  zero, so `Fixed(closing)` and `Fixed(opening)` agreed on every one.

Gates: tabular oracle 106/106 (all 98 pre-existing unchanged), zero
font/metric fallback diagnostics and zero `table_limitation` on every
fixture; amsmath 59/59; `cargo test --release` (no `FLASHTEX_*` in the
environment) 171 passed, 0 failed; HW1/HW2 byte-identical to the #176
baseline, 3 pages and 692/698 items each, 0 errors, 0 overfull, 0 font
diagnostics; real-world corpus identical to the baseline on all nine
fixtures.

New fixtures (references from local TeX Live 2025):
- 104-longtable-chunk-boundary: 210 rows, widest cell past the default
  chunk boundary, table opening page 1.
- 105-longtable-ltchunksize: `\LTchunksize=5`, widest cell in chunk six.
- 106-longtable-head-foot-only: `\endhead`/`\endfoot` and nothing else.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar force-pushed the rebase/184-longtable-inserts branch from 197bc78 to 12cc8e4 Compare September 14, 2026 02:30
GoKubar added a commit that referenced this pull request Sep 14, 2026
`crates/render-pipeline` builds against `vendor/compiler`, not `../compiler`,
so the longtable/multirow/booktabs/colortbl types #250 added to
`crates/compiler/src/tabular.rs` are invisible to the pipeline until the
mirror is re-exported. This is the re-pin #250, #251 and #253 each say is
"deliberately not in any of these PRs (vendor is the integration lane's)";
both pipeline halves were measured against exactly this re-pin, locally.

It rides with #251 rather than landing as its own PR (as #274's re-pin did)
because it is not standalone-safe in either direction, verified on this tree
against main 5baa9e6:

  - re-pin without #251: `cargo build --release` in crates/render-pipeline
    fails, `error[E0027]: pattern does not mention fields kern_left,
    kern_right` -- #250 grew `Entry::CMidRule` and `table.rs::from_compiler`
    matches `ct::Entry` exhaustively with no wildcard arm;
  - #251 without the re-pin: the same build fails on the types it is written
    against (`ct::Longtable`, `ct::Multirow`, `ct::ColorFill`,
    `ct::Entry::SpecialRule`/`Section`/`PageBreak`/...), which is what
    #251's own `rust render-pipeline` and `rust flashtex-cli` CI jobs show.

Either half alone leaves main red, so they land in one merge.

`git archive 5baa9e6 crates/compiler`, byte-identical to the real crate
apart from `PIN` (verified by re-archiving the previous pin 2495ebf and
diffing against the committed mirror: only `PIN` differed).

Implementation-Agent: integration lane (linux-primary, NixOS)
Commit-Executor: Claude Opus 5 via Claude Code (direct-agent Git under the
  observed-Cursor-limit user override)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar changed the base branch from rebase/176-table-packages-pipeline to main September 14, 2026 06:01
@GoKubar
GoKubar merged commit d837c29 into main Sep 14, 2026
13 of 20 checks passed
@GoKubar
GoKubar deleted the rebase/184-longtable-inserts branch September 16, 2026 04:17
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