Skip to content

render-pipeline: footnotes at the column foot (\footins, \footnoterule, splitting, two-column) - #140

Merged
jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/footnotes-render
Sep 13, 2026
Merged

jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/footnotes-render

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Footnotes in the render pipeline, implemented in its own page builder (pagebuild.rs, typeset/footnotes.rs). crates/page-builder is used as a reference only, not adopted. Based on main 85ec30c; no vendor edits, no stacking.

What it does

  • Mark (\@makefnmark): the number at \sf@size, raised by sup2 of the lmsy optical size LaTeX loads (TeX §758), with \scriptspace inside the box. \nobreak goes before it and the space factor is kept.
  • Note (\@footnotetext + article \@makefntext):
    • set in \footnotesize at \columnwidth, with the \hb@[email protected]{\hss mark} box;
    • first line at least \footnotesep high, last line at least \dp\strutbox deep;
    • \interfootnotelinepenalty plus the club/widow penalties.
  • Page building (pagebuild::break_pages_inserts, TeX §1008–1010 and §1018–1021):
    • the \insert migrates after the line holding the mark;
    • \skip\footins and each note are charged against the page goal, capped by \dimen\footins;
    • a note that doesn't fit is split at vert_break; the remainder is pruned with \splittopskip and opens the next page;
    • \floatingpenalty holds later notes after a split;
    • held notes at the document end get extra pages (\@doclearpage).
  • Column (\@makecol):
    • body, then \vfil for \newpage or the last page, then \skip\footins, \footnoterule (\kern-3pt, a 0.4pt × .4\columnwidth rule, \kern2.6pt), then the notes;
    • \vskip-\dp and \@textbottom, packed \vbox to\@colht;
    • handles raggedbottom and flushbottom.
  • Two-column documents get footnotes at the foot of each column.
  • \footnotemark and \footnotetext with optional numbers work.

Documents without footnotes keep the existing break_pages_shortened path.

Oracle (tests/footnotes_oracle.rs)

24 fixtures against pdflatex (MacTeX 2026). The generator is tools/footnotes-oracle/generate.py; expected data is committed and cargo never runs TeX. Gates: page count, every word within 0.5bp, every rule within 0.1bp.

Gated (19), all exact (worst word deviation 0.006bp, all rules within 0.1bp):

  • basics: single note, several notes, optional number, \footnotemark+\footnotetext (with and without an optional number), adjacent marks
  • page breaking: a long note split across pages, a note near the page bottom forcing a break, 18 notes on one page with hold-over, \newpage, the last page
  • classes and layout: twoside flushbottom, 11pt, 12pt, book chapter, sections, list item
  • two-column: notes per column, and a two-column split

Reported, not gated (5):

  • 10-report-chapter-reset: 632/634 words. The compiler never resets the footnote counter at \chapter; it has no \chapter parsing.
  • 12-thanks: the compiler strips \thanks.
  • 13-minipage: minipage footnotes (see below).
  • 14-multipar-note: the compiler closes a \footnote argument at a blank line, but \@footnotetext is \long. Separate compiler PR follows.
  • 15-math-note: math inside a note is set at body size; TexMathMetrics exists only for the class base size.

Gates

  • render-pipeline cargo test --release: all green (page_frame, floats_oracle, tabular_oracle, incremental, …). New pagebuild unit tests cover skip charging, split with remainder, and hold-over after a split.
  • Byte-identical v2 JSON and PDF against a main 85ec30c build for all nine real-world fixtures (HW1, HW2, article-twocolumn, cv, input-bibliography, lecture-notes, letter, math-sheet, unicode-accents). None of them use footnotes.

Composability and integration notes

Compiler asks

  1. Parse a \footnote/\footnotetext argument as \long (separate PR).
  2. Emit \thanks as Inline::Footnote inside the title/author inlines, with \@fnsymbol numbers and the counter reset after \maketitle, instead of stripping it. The pipeline already places notes anchored on title lines.
  3. Reset the footnote counter at \chapter in report/book.
  4. mpfootnote numbering (alph) inside minipage.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

\footnote, \footnotemark and \footnotetext now go through TeX's
insertion machinery instead of being set inline in the paragraph:

- the mark is \@makefnmark: the number at \sf@size, raised by sup2 of
  the lmsy font at the current size, \scriptspace inside the box, with
  \nobreak before it and the space factor kept;
- the note is set as \@footnotetext sets it: \footnotesize, the 1.8em
  \@makefntext mark box, \footnotesep strut, final strut depth,
  \interfootnotelinepenalty plus club/widow penalties, \columnwidth;
- pagebuild::break_pages_inserts charges \skip\footins and each note
  against the page goal (TeX 1008-1010), splits a note that does not fit
  at vert_break, holds over what waits (\floatingpenalty after a split),
  and \@makecol sets \skip\footins, \footnoterule and the notes in the
  \vbox to\@ColhT (raggedbottom, flushbottom, \newpage and last page).

Two-column documents get footnotes per column. Documents without
footnotes keep the existing page builder: HW1, HW2 and the other seven
real-world fixtures render byte-identical to main.

Oracle: 24 fixtures vs pdflatex (MacTeX 2026), generator and expected
data committed; 19 are gated and match every word within 0.5bp (worst
0.006bp) and every rule within 0.1bp. Reported, not gated: \thanks and
report chapter reset (compiler), minipage footnotes (hook only), a
blank line in a note (compiler), math inside a note (body size).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude footnotes render, 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 commented Sep 13, 2026

Copy link
Copy Markdown
Member

Merged to main via integration/2026-09-13k (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