Skip to content

Reset block numbering within worksheets and handouts - #3050

Merged
rbeezer merged 1 commit into
PreTeXtBook:masterfrom
rbeezer:handout-worksheet-numbering-reset
Jul 17, 2026
Merged

Reset block numbering within worksheets and handouts#3050
rbeezer merged 1 commit into
PreTeXtBook:masterfrom
rbeezer:handout-worksheet-numbering-reset

Conversation

@rbeezer

@rbeezer rbeezer commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Reported on pretext-support: numbered blocks (definitions, theorems, etc.) in sibling worksheet or handout divisions don't restart their numbers in HTML, even though the PDF numbers them correctly.

For example, a chapter with two handouts, ten definitions each, produces:

  • PDF: 1.1.11.1.10, then 1.2.11.2.10
  • HTML: 1.1.11.1.10, then 1.2.111.2.20 — the third component never resets

Cause. The two formats number these blocks by different routes. LaTeX uses its own block tcolorbox counter, declared number within=section; since each handout is emitted as a \section, the counter resets per handout. HTML uses the @serial stamped during assembly. In the assembly serial-stamp pass, the $b-terminal test — which decides whether a division opens its own block-numbering scope — listed only the traditional subdivisions (chapter, section, …) and omitted the specialized ones. So a chapter whose children are handouts is misjudged "terminal," opens a single scope, and pools the blocks of all its handouts into one running count. Using sections in place of handouts avoids the bug precisely because section was in the test.

Origin. The $b-terminal predicate was introduced in #2885 (serial numbers for equations and footnotes), where the omission was already present — so equation and footnote numbering inside sibling worksheets/handouts has had the same latent flaw. It surfaced as this report once #2904 (serial numbers for blocks) routed the shared block counter through the same predicate.

Fix. Add the specialized divisions (exercises, worksheet, handout, reading-questions, references, glossary, solutions) to the $b-terminal test, so each opens its own scope and its blocks restart, matching the print output.

Testing. A synthetic two-handout document now numbers 1.2.11.2.3 in HTML, matching the PDF. A before/after build of the sample article (via its publication file) shows no numbering changes — only build timestamps differ.

Claude Opus 4.8, acting as a coding assistant for Rob Beezer

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rbeezer
rbeezer merged commit 9c25f6f into PreTeXtBook:master Jul 17, 2026
@rbeezer
rbeezer deleted the handout-worksheet-numbering-reset branch July 18, 2026 00:17
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