Skip to content

compiler: \numberwithin, \counterwithin and subequations on one counter table (display-math blocker 2 of #146) - #155

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

jay3332 merged 1 commit into
mainfrom
agent/kabir-claude/equation-numbering

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Part B of the two blockers left by #146 (fixtures 17 \numberwithin{equation}{section} and 18 subequations).

What

  • xref::Counters is the one counter mechanism. It keeps LaTeX reset lists (\@addtoreset, several parents, transitive \@stpelt) and \the<name> as pieces (\the<parent>, text, \arabic/\alph/\Alph/\roman/\Roman). The parser's equation_counter/figure_counter u32s are gone. define_body_counters() defines equation/figure/table/parentequation, so report/book (footnotes-2's Counters::report()) can reuse it and add counter_within(.., "chapter").
  • amsmath \numberwithin[\style]{counter}{parent} works in the preamble or the body. An unknown counter gives LaTeX's "No counter defined" error. A \newtheorem counter follows section through the existing theorem numbering. For the theorems lane: they can switch to Counters::define + step.
  • \counterwithin(*)/\counterwithout(*): HOST_PRELUDE lets these tex-expansion kernel primitives pass through to the parser. \numberwithin[\alph]'s format is renamed like enumitem label markers, so the engine's \alph doesn't consume ]. No tex-expansion edits. If compiler: adopt tex-expansion (r2) without the HW1 keystroke regression (supersedes #108) #130's LaTeX layer later owns counters, this parser path is the one to retire.
  • amsmath subequations: \refstepcounter{equation} (a leading \label gets the parent number), \theequation = frozen parent + \alph, and the counter is restored from parentequation at \end.
  • Supported inventory regenerated: numberwithin, counterwithin, counterwithout, subequations. apps/mac's bundled supported-latex.json is not touched here (no apps/ edits); it needs the usual sync.

Evidence

pdflatex numbers for display-placement fixture 17: (1.1) (2.1), \eqref (2.1). Fixture 18: (1) (2a) (2b) (2c) (3), with \eqref{e:sub} = (2) and \eqref{e:s1} = (2a).
cargo test --release (compiler): every suite passes. That includes lib 257 (new xref and parser tests), new tests/equation_numbering.rs 3 (full expansion path), supported_latex 8, xref_toc 7 and corpus_gate.

Re-pin order

A (#148, math-layout) and B (this PR) are independent. C (render-pipeline) re-pins both.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…ons on one counter table

Equations and figure captions now number through xref::Counters, the
table sections already used, instead of plain u32 counters:

- Counters keep LaTeX's reset lists (\@addtoreset, several parents) and
  \the<name> as pieces (\the<parent>, text, \arabic/\alph/\Alph/
  \roman/\Roman{counter}); article defines equation, figure, table and
  amsmath's parentequation (define_body_counters, for report/book to
  reuse with chapter resets).
- amsmath \numberwithin[\style]{counter}{parent} (preamble or body):
  reset by parent, printed \theparent.\style{counter}; unknown counters
  are LaTeX's "No counter defined" error. A \newtheorem counter follows
  section through the existing theorem numbering.
- \counterwithin(*)/\counterwithout(*): the expansion prelude lets them
  pass to the parser (they were engine primitives the parser never saw).
  A \numberwithin[\alph] format is renamed like enumitem label markers
  so the engine's \alph does not read ']'.
- amsmath subequations: \refstepcounter{equation} (a \label right after
  \begin gets the parent number), \theequation = frozen parent + \alph,
  counter restored from parentequation at \end.

pdflatex numbers of display-placement fixtures 17/18: (1.1) (2.1), and
(1) (2a) (2b) (2c) (3) with \eqref{sub} = (2). Supported inventory
regenerated (numberwithin, counterwithin, counterwithout, subequations).
cargo test --release (compiler): all suites pass (lib 257, new
tests/equation_numbering.rs 3, supported_latex 8, xref_toc 7).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude math glue + numbering, 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
Conflicts: parser.rs modules (+ algorithmic), initialisers/fields (main's subequations + #159's algorithm_counter; equation/figure counters stay in xref::Counters per #155), preamble dispatch (hyperref/boxes/counter commands + algnewcommand/algrenewcommand/algsetup/floatname), \caption (algorithm branch before main's figure/table check), float \begin/\end (figure, table, algorithm, algorithm*; #159's stale theorem clause dropped), package matches (listings + algorithm packages); supported.rs TEXT_EXTRA_ARMS and caption/item descriptions (main's item [label]). Integration fix: parser/algorithmic.rs Block::Styled gains #147's lists/line_break_before. Generated docs took main.

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
@jay3332
jay3332 merged commit ddead1a into main Sep 13, 2026
11 of 18 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/equation-numbering branch September 13, 2026 18:12
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