Skip to content

compiler: parse a \footnote argument as \long - #142

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/footnote-long-argument
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/footnote-long-argument

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

In latex.ltx, \@footnotetext is \long, so a blank line inside \footnote{...} or \footnotetext{...} is a paragraph break in the note.

The parser was closing the argument at the blank line. It then reported "missing its closing brace" and "unmatched '}'", and the second half of the note ended up in the host paragraph. The argument now goes through long_required_group. An argument that is never closed is still closed at the end of its first paragraph.

Remaining compiler asks from #140, not in this PR:

  • \thanks as Inline::Footnote with \@fnsymbol numbers
  • the footnote counter reset at \chapter, which needs \chapter parsing
  • mpfootnote alph numbering in minipage

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

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
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 14, 2026
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.

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

Ported from PR #142, which merged cleanly but did not compile: it called
`long_required_group`, a thin wrapper `main` no longer has. What that wrapper
wrapped is still there -- `required_group_bounded(command, span, long)` --
and its `long` arm already does exactly what this needs: a paragraph boundary
inside the argument is recorded but does not end it, and an argument that is
never closed at all is still closed at the end of its first paragraph, so a
missing brace cannot swallow the document. Until now nothing passed `true`,
so the flag had no caller; `\footnote`/`\footnotetext` is the first, and the
doc comment that lived on the deleted wrapper moves onto it. Behaviour is
unchanged from #142.

crates/compiler `cargo test --release` on this tree: 471 passed, 0 failed.
The same command on `main` (eea975c) gives 469, so the delta is exactly this
PR's own `tests/footnote_long_argument.rs`.

Rebase-Agent: Claude Opus 5 (engine lane, linux-primary)
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
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
compiler: parse a \footnote argument as \long (port of #142 to required_group_bounded)
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: 13da5d9 same title (PR #259)

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/footnote-long-argument 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