Skip to content

render-pipeline: \@makecol packs the whole float+footnote column to \@colht (extends #154) - #192

Closed
GoKubar wants to merge 1 commit into
agent/kabir-claude/footnotes-2from
agent/kabir-claude/float-notes-column
Closed

GoKubar wants to merge 1 commit into
agent/kabir-claude/footnotes-2from
agent/kabir-claude/float-notes-column

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

This extends draft #154; it does not replace it. Base branch is
agent/kabir-claude/footnotes-2 @ 8217e984, not main — #154 owns the
footnotes-through-floatpage work and must merge first (it in turn carries
#140 and wants compiler #153). This branch is the two corrections its model
needs plus a fixture set that exercises them.

This branch: agent/kabir-claude/float-notes-column @ 4d8b4cae.

I had first written an independent implementation on current main
(agent/kabir-claude/float-notes-reference @ 41b10c1d) before #154 was
pointed out to me. It is pushed for reference/evidence only and should not
be merged; everything of value in it is either already in #154 or in this
branch.

How #154 was reviewed

The ten fixtures below were built against local pdflatex first, then run
against #154's own branch in a scratch checkout. #154 gets 7 of 10
exactly
; the three failures isolate to two causes.

fixture #154 @ 8217e984 + fix 1 this branch
02-bottom-float-note 508/581 words, 0/2 rects 561/581, 1/2 581/581, 2/2
06-float-page-note 617/714 words, 1/2 rects 714/714, 2/2 714/714, 2/2
08-twocolumn-float-note 897/1217 words 897/1217 1217/1217
the other seven exact exact exact

"+ fix 1" is #154's own tree with only the one-line change below, which is
how each cause was attributed rather than guessed.

These are not artifacts of #154's older base: on its base the no-float
two-column footnote fixtures 11-twocolumn (2022/2022) and
20-twocolumn-split (2312/2312) match main exactly, so the differences are
in the footnote-plus-float column assembly.

Fix 1 — TeX §1005's shrink allowance

The page-builder loop's box-overflow shortcut read

if total > is.goal + 1e-9 && lines_seen > 1 {

but §1005 only reaches awful_bad when page_total - page_goal > page_shrink. In a body of \parskip 0pt plus 1pt the available shrink is
zero, which is why the float-only builder never needed the term;
\skip\footins's minus 2pt (and an h float's \intextsep) supplies
some, and the column was losing the line TeX keeps. On
06-float-page-note that was one body line on page 1 and an 11.36 bp error
in the \footnoterule.

Fix 2 — \@makecol packs one \vbox to\@colht

The default build/column/outputbox plug is footnotes-floats-legacy:
\@outputbox@reinsertbskip, \@outputbox@appendfootnotes, then
\@outputbox@attachfloats. The notes attach to \box\@cclv before
\@combinefloats wraps the floats around it, so the column is

top floats, \floatsep between them, \textfloatsep,
the body, the \vfil \@outputbox@removebskip lifted off its end,
\skip\footins, \footnoterule, the notes,
\textfloatsep, the bottom floats, \vskip-\dp, \@textbottom

\@cflt and \@cflb build plain \vboxes; only \@make@normalcolbox
packs \vbox to\@colht. So one glue set ratio covers the body's glue,
\skip\footins (plus 4pt minus 2pt) and both \textfloatseps
(plus 2pt minus 4pt) together — \@colht, not \@colroom, is the size to
reach.

#154 set the body and notes to \@colroom on their own and then placed the
bottom floats by a rule (flush at \@colht when there is a \vfil or
\flushbottom, at their natural position otherwise). That leaves
\skip\footins and the float skips out of the distribution, which is the
1.276 bp on 02-bottom-float-note (rule, notes and bottom float all high)
and the 1.137 bp on 08-twocolumn-float-note.

pagebuild::make_column now takes the column's float material
(ColumnFloats: the top and bottom float heights, \floatsep,
\textfloatsep) and returns where it put each float box
(FloatPlacement). That replaces the keep_depth flag and all the
text_off shifting in floatpage. break_pages_inserts passes an empty
ColumnFloats and is byte-for-byte unchanged.

Verified against pdflatex, not by analogy

\@makecol, \@make@normalcolbox, the build/column/outputbox plugs,
\@cflt, \@cflb, \@comflelt, \@specialoutput and \@doclearpage were
read from latex.ltx as shipped by TeX Live 2025. The column order and the
glue that carries it were then confirmed against a \tracingoutput=1 dump of
a page holding a top float, a note and a bottom float, which shows exactly:

\vbox(550.0+0.0)x345.0, glue set 309.53804fil
...\vbox(83.94444+0.0)x345.0          % the top float
...\glue 12.0 plus 2.0 minus 2.0      % \floatsep
...\glue -12.0 plus -2.0 minus -2.0   % \vskip-\floatsep
...\glue 20.0 plus 2.0 minus 4.0      % \textfloatsep
...\glue(\topskip) 1.85997            % \box\@cclv starts
...   (body lines)
...\glue 0.0 plus 1.0fil              % the reinserted \vfil
...\glue 9.0 plus 4.0 minus 2.0       % \skip\footins
...\kern -3.0 \rule(0.4+0.0)x137.9979 \kern 2.6
...\hbox(6.68999+2.85002)x345.0       % the note
...\glue 20.0 plus 2.0 minus 4.0      % \textfloatsep
...\vbox(63.94444+0.0)x345.0          % the bottom float
...\glue 12.0 plus 2.0 minus 2.0 \glue -12.0 plus -2.0 minus -2.0
...\glue 0.0                          % \vskip-\@outputbox@depth
...\glue 0.0 plus 0.0001fil           % \@textbottom (\raggedbottom)

Fixtures (10)

fixtures/float-notes/, generated by tools/float-notes-oracle/generate.py,
gated by tests/float_notes_oracle.rs. Words within 0.5 bp, rules within
0.1 bp, image rectangles within 1 bp, page counts exact, and the test fails
on any font_unavailable, required_metrics_unavailable,
ec_metrics_unavailable, font_outline_substituted, image_unavailable,
unsupported_block, float_content_unsupported or float_too_large — a
fallback run fails rather than passes.

  • 01-top-float-note — [t] float and a note on one page.
  • 02-bottom-float-note — [b] float, notes set above it (\@cflb).
  • 03-note-defers-float — a note tall enough that \@pageht
    (\ht\footins + \skip\footins + \dp\footins) makes \@addtocurcol refuse
    the float.
  • 04-deferred-float-notes — three [t] floats competing with notes;
    topnumber defers one.
  • 05-split-note-float — a note §1010 splits under a top float, the
    remainder held over.
  • 06-float-page-note — a [p] float page (no body text) with a note
    pending for the next column.
  • 07-here-float-note — an h float (\@midlist, \@textfloatsheight,
    \intextsep) with notes.
  • 08-twocolumn-float-note — two columns, each its own \@colroom and
    \footins.
  • 09-clearpage-note-float — \@doclearpage's \ifvoid\footins else-branch:
    one more ordinary column before \@makefcolumn.
  • 10-top-bottom-notes — top float, bottom float and three notes on one page,
    so every glue in the column is set by the one ratio.

All ten: pages exact, every word within 0.005 bp, every rule and image
rectangle matched, zero diagnostics.

reference_engine: pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025/nixos.org),
recorded in each expected file's header. This is a NixOS host, not MacTeX. No
committed MacTeX-generated expected data was regenerated — the MacTeX 2026
data under fixtures/footnotes/ and fixtures/floats/ is untouched.

Gates

Control is #154 @ 8217e984 in a scratch checkout, so the two sides differ
only by this commit. Every run used the repository's bundled symlink-free
font tree (apps/mac/Fonts plus its three TFM directories) and never the
system TeX Live.

Gate #154 control This branch
float_notes_oracle (new) 7/10 fixtures 10/10
cargo test --release, fonts configured 141 passed, 7 failed 142 passed, 7 failed — same seven
cargo test --release, no FLASHTEX_* 148 passed, 0 failed 149 passed, 0 failed
per-fixture oracle lines (81 fixtures incl. footnotes_oracle 01–39) — identical
amsmath corpus 42/42 42/42
HW1 / HW2 rendering-v2 3 pages, 692 / 694 items byte-identical, 0 errors, 0 overfull, 0 font diagnostics
Real-world corpus (--no-oracle --no-pixels) 9 fixtures identical: same status, pages and every diagnostic

The +1 in both test counts is the new float_notes_oracle. The seven
failures with fonts configured are the same set on both sides
(cm_less_symbols…, footnotes_against_pdflatex, mathbb…, mathcal…,
missing_required_metrics…, page_frame_against_pdflatex, varnothing…);
they are partial-font control tests contaminated by the global font env, not
breakage from this change, and the per-fixture oracle lines they print are
identical on both sides.

Note on the amsmath and corpus numbers: #154's base carries a 42-fixture
amsmath corpus and a 9-fixture real-world corpus. On current main those are
59 and 10; the reference branch measures 59/59 there. Both sides of each
comparison above use the same base, which is what makes them comparable.

What is still open

  • \@kludgeins (\@make@specialcolbox, the \enlargethispage /
    marginpar-overflow path) is not modelled; a column with \@kludgeins and
    footnotes would take a different \@makecol branch.
  • The non-legacy build/column/outputbox plugs (space-footnotes-floats,
    floats-space-footnotes, …) are not modelled. Only the default
    footnotes-floats-legacy is, which is what every standard class gets.
  • \topfigrule/\botfigrule are \relax in the standard classes and are
    not drawn.
  • footnotes_against_pdflatex fails on both sides on 21-book-chapter
    (807/809 words). Pre-existing, not touched here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…ColhT

Extends draft #154 (`agent/kabir-claude/footnotes-2` @ 8217e98), which this
branch is based on and does not replace. #154 already carries the insertion
state through the float paginator; these are the two places its model and
pdflatex disagree, both found by ten new fixtures and both measured against
local pdflatex (TeX Live 2025).

1. **§1005's shrink allowance.** The box-overflow shortcut fired at
   `total > \pagegoal`, but TeX only calls a page hopeless once the excess
   passes what the glue can shrink. A body of `\parskip 0pt plus 1pt` has no
   shrink, so this never showed without insertions; `\skip\footins`'s
   `minus 2pt` (and an `h` float's `\intextsep`) supplies some, and the
   column lost the line TeX keeps. `06-float-page-note` was a body line short
   on page 1 with the `\footnoterule` 11.36 bp high.

2. **One `\vbox to\@colht`, not a body packed to `\@colroom`.** `\@makecol`
   attaches the notes to `\box\@cclv` first (the default
   `build/column/outputbox` plug is `footnotes-floats-legacy`) and only then
   `\@combinefloats` wraps the floats around that, so the column is

       top floats, \floatsep between them, \textfloatsep,
       the body, the \vfil \@outputbox@removebskip lifted off its end,
       \skip\footins, \footnoterule, the notes,
       \textfloatsep, the bottom floats, \vskip-\dp, \@textbottom

   `\@cflt` and `\@cflb` build plain `\vbox`es and only
   `\@make@normalcolbox` packs `\vbox to\@colht`, so a single glue set ratio
   covers the body's glue, `\skip\footins` (`plus 4pt minus 2pt`) and both
   `\textfloatsep`s (`plus 2pt minus 4pt`) together. Setting the body and
   notes to `\@colroom` on their own and then placing the bottom floats by a
   rule (flush at `\@colht` with a `\vfil` or `\flushbottom`, natural
   otherwise) gives `\skip\footins` no share of the slack: on
   `02-bottom-float-note` the rule, the notes and the bottom float sat
   1.276 bp high, and on `08-twocolumn-float-note` the second column's body
   sat 1.137 bp high from its fourth line down.

   `pagebuild::make_column` now takes the column's float material
   (`ColumnFloats`) and returns where it put each float box
   (`FloatPlacement`), which replaces the `keep_depth` flag and the
   `text_off` shifting in `floatpage`. `break_pages_inserts` passes an empty
   `ColumnFloats` and is unchanged.

`\@cflt`/`\@cflb`/`\@makecol`/`\@specialoutput` were read from latex.ltx as
shipped by TeX Live 2025, and the column order was confirmed against a
`\tracingoutput=1` dump of a page carrying a top float, a note and a bottom
float.

## Fixtures

Ten under `fixtures/float-notes/`, with `tools/float-notes-oracle/generate.py`
and the `float_notes_oracle` test: top float + note, bottom float + note
(notes above the float), a note that defers a float through `\@pageht`, three
competing `[t]` floats with notes, a note split under a top float, a `[p]`
float page with a note pending, an `h` float with notes, two-column,
`\clearpage` with a note and deferred floats, and a page with a top float, a
bottom float and three notes.

**reference_engine: pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025/nixos.org)**
— generated on this Linux host, recorded in each expected file's header.
Unlike the MacTeX 2026 data under `fixtures/footnotes/` and
`fixtures/floats/`, none of which is regenerated here.

Implementation-Agent: engine-engineer (kabir-claude float-notes lane)
Commit-Executor: engine-engineer (direct git, Cursor usage limit fallback)

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

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: 84d104c same title

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/float-notes-column 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