Skip to content

compiler: \thanks as symbol footnotes, report/book \chapter counters, minipage footnote marks - #153

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

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

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Compiler half of the footnote follow-up. Includes #142 (\footnote argument parsed as \long), merged into this branch; base main. The render half is #154 (agent/kabir-claude/footnotes-2), which gates its \thanks/chapter/multi-paragraph fixtures once vendor/compiler is re-pinned to this change.

What changes (crates/compiler/src/parser.rs, xref.rs)

  • \thanks in \title/\author/\date is no longer stripped with a warning. It becomes an Inline::Footnote at its place in the title block, numbered \@fnsymbol\c@footnote in title → authors → date order: ∗ † ‡ § ¶ ‖ ∗∗ †† ‡‡. A tenth is diagnosed (\@ctrerr) and printed in arabic. \maketitle ends with \setcounter{footnote}{0}.
  • \chapter[*][short]{title} is parsed when the class is report or book.
    • The numbered form steps chapter and resets section (and below), footnote, figure and equation (\@addtoreset).
    • Once a chapter exists, \thesection, Figure N: captions and equation numbers print as <chapter>.<n>.
    • The title is kept as a bold paragraph, because the renderer owns the head's layout and already strips that source range.
    • article still diagnoses \chapter. The arm is class-guarded, so the supported inventory is unchanged.
  • minipage: \footnote/\footnotetext inside use mpfootnote, zeroed at each \begin{minipage}, with \alph marks. \footnotemark keeps footnote. The environment itself is still unimplemented.

Inline::Footnote/Block shapes are unchanged, so no renderer match needs to change.

Tests

  • New tests/footnote_counters.rs (6): symbol order and counter restart, the tenth \thanks, report chapter resets with section/equation labels and \chapter*, book figure numbers, article without chapters, minipage \alph marks.
  • tests/maketitle.rs: the \thanks test now asserts a symbol footnote instead of the old warning.
  • cargo test --release --no-fail-fast (crates/compiler): all green, supported_latex inventory tests included.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 13, 2026 08:03
latex.ltx defines \@footnotetext with \long: a blank line inside
\footnote{...} or \footnotetext{...} is a paragraph break in the note.
The parser closed the argument at the blank line instead, reported a
missing brace and an unmatched '}', and moved the rest of the note into
the host paragraph. The argument now uses long_required_group; an
argument that is never closed is still closed at the end of its first
paragraph.

Found by the render-pipeline footnote oracle (fixture 14-multipar-note).

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
… minipage footnote marks

\thanks in \title/\author/\date becomes an Inline::Footnote at its place in the title block, numbered \@fnsymbol\c@footnote in title, author, date order (U+2217, U+2020, U+2021, section, pilcrow, U+2016, then doubled; a tenth is diagnosed and printed arabic); \maketitle ends with \setcounter{footnote}{0}. The old strip-with-warning path is gone.

report/book: \chapter[*][short]{title} is parsed. The numbered form steps chapter and resets section, footnote, figure and equation (\@addtoreset); \thesection, figure captions and equation numbers print as <chapter>.<n> once a chapter exists. The title stays a bold paragraph (the renderer owns the head layout and strips it by source range); article keeps diagnosing \chapter.

minipage: \footnote/\footnotetext inside use mpfootnote (zeroed at each \begin{minipage}, \alph marks); \footnotemark keeps footnote.

Includes PR #142 (footnote argument parsed as \long).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude footnotes 2, 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
Semantic overlap with #153 resolved to one counter model: equation/figure/table step through xref::Counters (#155); Counters::report() registers them within chapter (#153's numbering), so \chapter's step resets them, and #153's hand-kept equation/figure/table counters and within_chapter are removed. Kept #131's caption/equation hyperref anchors and label_inline. Conflicts: HOST_PRELUDE (amsthm defaults + \counterwithin/\counterwithout pass-through), parser.rs fields/dispatch/captions/bibliography OpenList + subequations begin/end/equation/multirow/labels, supported.rs (counter commands + main's hyperref url/href). Also: Counters::set_within rewritten on #155's Vec reset_by/pieces; #149's \numberwithin arm and fn removed (shadowed #155's counter_numbering with [style]); #155's theorem-counter special case removed (theorem counters are Counters entries since #149); TEXT_EXTRA_ARMS drops numberwithin (now in BUILT_INS); unused HashMap import in parser/boxes.rs.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, 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
…ession handoff)

Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150,
#155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded
in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169,
#148, #161, then the inventory regeneration and stages 2-4. The helper scripts
under tools/ hard-code the original worktree path.

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

Every stage 1 merge took main's side of the generated inventory and deferred
the regeneration to the end of the stage. Running
crates/compiler/scripts/render_supported_latex.sh picks up #131, #137, #144,
#147, #149, #150, #153, #155, #159, #163, #164, #166 and #169, so
supported_latex::generated_artifacts_are_current passes again.

The TeX Live-derived canonical denominator is deliberately untouched: this
machine has TeX Live 2025, not the MacTeX the committed file was pinned from.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-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
… minipage footnote marks

- **`\thanks`** in `\title`/`\author`/`\date` is no longer stripped with a
  warning. It becomes an `Inline::Footnote` at its place in the title block,
  numbered `\@fnsymbol\c@footnote` in title -> authors -> date order:
  * † ‡ § ¶ ‖ ** †† ‡‡. A tenth is diagnosed (`\@ctrerr`) and printed in
  arabic. `\maketitle` ends with `\setcounter{footnote}{0}`.
- **`\chapter[*][short]{title}`** is parsed when the class is report or book.
  The numbered form steps `chapter`, which resets `section` (and below),
  `figure`, `table` and `equation`; `\thesection`, `Figure N:` captions and
  equation numbers then print `<chapter>.<n>`. The title is kept as a bold
  paragraph, because the renderer owns the head's layout. article still
  diagnoses `\chapter`; the arm is class-guarded, so the supported inventory
  is unchanged.
- **minipage**: `\footnote`/`\footnotetext` inside use `mpfootnote`, zeroed at
  each `\begin{minipage}`, with `\alph` marks. `\footnotemark` keeps
  `footnote`. The environment itself is still unimplemented.

`Inline::Footnote`/`Block` shapes are unchanged, so no renderer match changes.

Reconstructed from PR #153 rather than rebased: that branch predates main's
`crate::expansion` refactor, and its `parser.rs` hunks drag four functions
main has since deleted or moved (`declare_math_operator`, `define_macro`,
`expand_macro`, `expand_macro_word`) back in behind one 297-line conflict
whose other side is empty. Only `chapter()` from that hunk is kept.

The substantive change is where the chapter prefix lives. #153 carried its own
`equation_counter`/`figure_counter` fields and a `within_chapter(value)` helper
that formatted `"{chapter}.{value}"` by hand; main has replaced those fields
with `crate::xref::Counters`, which already models `\@addtoreset` and
`\the<name>`. So `report()` registers `equation`/`figure`/`table` as reset by
`chapter`, `chapter()` stops zeroing them one by one (`step` resets every
descendant), and `within_chapter` is gone -- each of its four call sites is
just `counters.step(...)` now.

That needed one thing the counter table could not express. report.cls prints

    \renewcommand\thefigure{\ifnum \c@chapter>\z@ \thechapter.\fi \@Arabic\c@figure}

and the guard is load-bearing: a figure in the front matter, before any
`\chapter`, is "1", not "0.1". `\counterwithin` (`Counters::counter_within`)
writes the prefix unconditionally, which is right for `\numberwithin` and
wrong here, and `\thesection` in report.cls is indeed unconditional. So `Piece`
gains `IfPositive(counter, then)` -- `\ifnum \c@<counter>>\z@ <then>\fi` -- and
`format` grows a `format_pieces` arm to recurse into it. New
`report_prefixes_body_counters_with_the_chapter_only_once_one_exists` covers
the front-matter case, the reset, the unconditional `\thesection`, and
`\setcounter{chapter}{0}` putting the guard back (book.cls's front matter).

`footnote` is not in the counter table yet, so `\@addtoreset{footnote}{chapter}`
stays an explicit assignment in `chapter()`, as in #153.

crates/compiler `cargo test --release --no-fail-fast`: 478 passed, 0 failed.
main (eea975c) on the same tree is 469 and this branch's base (the #142 port)
is 471, so the delta is this PR's own 6 `footnote_counters` tests plus the new
`xref` one. #153's own six pass unmodified against the reconstruction.

Rebase-Agent: Claude Opus 5 (engine lane, linux-primary)
Implementation-Agent: Claude Opus 5 (subagent kabir-claude footnotes, 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
…math

Floats: `floatpage::paginate` carries the page builder's `InsertState` (notes
charged against `\@colroom`, `\@pageht` counts `\footins`, split and held
notes, the `\@doclearpage` notes page) and sets a note column as `\@makecol`:
body, `\skip\footins`, `\footnoterule` and notes, then bottom floats.
`pagebuild::settle_inserts` factors out sections 1018-1021.

`\thanks`: title marks are `\rlap`ped and the notes follow the title's last
line; `\@fnsymbol` marks take ts1-lmr TFM metrics. Mark clearance is depth +
x-height/4 (rule 18c). A paragraph break in a note sets `\par` and the 1em
`\parindent` box. Math in notes uses the `\footnotesize` math fonts (8/6/5,
10/7/5); 9pt keeps body metrics with a diagnostic.

Oracle: 15 new pdflatex fixtures (floats t/b/p/h, split, deferred; `\thanks`;
report/book chapters; note math; minipage).

Rebased from PR #154 onto main 190 commits later. Its first commit
(`d7ddf641`, footnotes at the column foot) is already on main; only this one
was outstanding. Four places where main had moved:

- `Context` gained `multicol::State` on main while this branch gained
  `rlap_marks`/`math_fonts_sized`; all three are kept.
- Inline math. This branch changed `math_box` to take the text size, so a
  formula in a note is laid out with that size's math fonts; main meanwhile
  split a formula into `math_pieces` for inline line breaking. The two are
  orthogonal: `math_box(list, span, false, size)` feeding `math_pieces(rec,
  size, span)`. The `\LaTeXe` logo's `\varepsilon` -- main's only other
  `math_box` caller -- passes the surrounding text size, so a logo inside a
  note follows the note.
- `TexMathMetrics::new` gained a `cmex_designs` parameter on main (family 3
  at amsfonts' designs rather than `omxcmex.fd`'s `sfixed` 10pt) and
  `fraktur`/`alphabets` fields. This branch refactored the same function into
  `at_text_size`, which is what makes 8pt note math possible at all. Merged:
  `at_text_size(text_pt, cmex_designs, otf, fonts) -> Option<Self>` keeps
  main's designs switch and both new fields, and `new` delegates to it.
- `BoxRec::Rule` gained a `bottom` field on main; the `\parindent` box of a
  note's paragraph break sets it to 0 (the baseline), and main's
  `width <= 0 || height <= 0` guard already covers the zero-height rule this
  branch was skipping with an arm of its own.

Footnotes oracle, `vendor/compiler` re-pinned locally to the reconstructed
#153: `compiler_has_footnote_counters()` probes true, so the seven
`NEEDS_COMPILER` fixtures -- `\thanks` symbol marks, report/book chapter
resets and the `\long` note argument -- are gated rather than merely
measured, and they pass. 39 fixtures: 34 gated and matching pdflatex, 5 in
`REPORTED` for constructs that are still unimplemented.

`cargo test --release` on crates/render-pipeline: 202 passed, 0 failed --
the same count as main, because the 15 new fixtures live inside the existing
oracle test rather than adding test functions.

Rebase-Agent: Claude Opus 5 (engine lane, linux-primary)
Implementation-Agent: Claude Opus 5 (subagent kabir-claude footnotes 2, 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
compiler: \thanks as symbol footnotes, report/book \chapter counters, minipage footnote marks (reconstruction of #153 on the current expansion code)
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: b50d84b same title (PR #281)

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/footnotes-2-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