Repository navigation
compiler: \thanks as symbol footnotes, report/book \chapter counters, minipage footnote marks (reconstruction of #153 on the current expansion code) - #281
Merged
Conversation
… 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
force-pushed
the
rebase/142-footnote-long-argument
branch
from
September 14, 2026 02:22
f99c8a8 to
13da5d9
Compare
GoKubar
force-pushed
the
rebase/153-footnotes-2-compiler
branch
from
September 14, 2026 02:22
0024942 to
b50d84b
Compare
GoKubar
changed the base branch from
rebase/142-footnote-long-argument
to
main
September 14, 2026 06:12
… into integ/281-test # Conflicts: # crates/compiler/src/parser.rs
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
… regions (#343) Closes the second silent-content-loss bug: every \footnote on a page containing a float was dropped. floatpage::paginate now charges the longtable region's reserve alongside the insertion state, so a continuation foot and a note compete for one page as in TeX, and settle_inserts is shared rather than duplicated. Measured end to end: hyperref-toc, lab-report and lmodern-report were silently dropping footnote text on main and now set it; 17 of 23 documents byte-identical. Footnotes oracle 19/24 -> 35/39, float-notes 10/10, tabular still 106/106, amsmath 59/59, HW1/HW2 unchanged. Carries the vendor re-pin, which un-inerts #259, #281, the ~/\nobreakspace fix, text-mode spacing in macro bodies and the amsmath limit operators.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reconstruction of #153 on current
main. Supersedes #153 — its branch is untouched. Stacked on #259 (the port of #142, which #153 included).\thanksas symbol footnotes, report/book\chaptercounters, minipage footnote marks. Construct list unchanged from #153.Why this is a reconstruction and not a rebase
#153's branch predates
main'scrate::expansionrefactor. Cherry-picking it produces eight conflicts, and one of them is a 297-line block whoseHEADside is empty — it dragsdeclare_math_operator,define_macro,expand_macroandexpand_macro_wordback in, none of which exist onmainany more. That is what the integration lane hit when it marked #153 "aborted as non-trivial". Onlychapter()from that hunk is kept.Where the chapter prefix lives now
#153 carried its own
equation_counter/figure_counterfields and awithin_chapter(value)helper that formatted"{chapter}.{value}"by hand.mainhas replaced those fields withcrate::xref::Counters, which already models\@addtoresetand\the<name>— and whosedefine_body_countersdoc already anticipated this ("report/book registerequation/figure/tablewithinchapteron top of this").So:
Counters::report()registers them,chapter()stops zeroing them one at a time (stepresets every descendant), andwithin_chapteris gone — each of its four call sites is now justcounters.step(...).The one thing the counter table could not express
report.cls prints
and the guard is load-bearing: a figure in the front matter, before any
\chapter, is1, not0.1.\counterwithin(Counters::counter_within) writes the prefix unconditionally — correct for\numberwithin, wrong here — while\thesectionin report.cls genuinely is unconditional, so the two cases differ.Piecetherefore gainsIfPositive(counter, then)(\ifnum \c@<counter>>\z@ <then>\fi) andformatgrows aformat_piecesarm to recurse into it. The newreport_prefixes_body_counters_with_the_chapter_only_once_one_existscovers the front-matter case, the reset, the unconditional\thesection, and\setcounter{chapter}{0}putting the guard back (book.cls's front matter).footnoteis not in the counter table yet, so\@addtoreset{footnote}{chapter}stays an explicit assignment inchapter(), as in #153.Gates, measured on this tree
main@5e6c65becrates/compilercargo test --release --no-fail-fastThe delta over #259 is this PR's own 6
footnote_counterstests plus the newxrefone. #153's own six tests pass unmodified against the reconstruction, which is the real check that the intent survived: symbol order and counter restart, the tenth\thanks, report chapter resets with section/equation labels and\chapter*, book figure numbers, article without chapters, and minipage\alphmarks.The supported inventory is unchanged (the
\chapterarm is class-guarded), andtests/supported_latex.rs's drift gate passes without regeneration.Independently validated downstream
The footnotes oracle in #282 probes the vendored compiler (
compiler_has_footnote_counters()) and gates seven fixtures only when it has this change. Withvendor/compilerre-pinned to this branch the probe passes and all seven are asserted against pdflatex — including14-multipar-note, which onmainis 116 of 438 words. That is a stronger check on this PR than its own unit tests.Rebased and re-measured against
main5e6c65be.mainmoved 53 commits during this work, including changes toparser.rs,typeset.rsandmathtex.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