Reset block numbering within worksheets and handouts - #3050
Merged
rbeezer merged 1 commit intoJul 17, 2026
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Reported on pretext-support: numbered blocks (definitions, theorems, etc.) in sibling
worksheetorhandoutdivisions 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:
1.1.1–1.1.10, then1.2.1–1.2.101.1.1–1.1.10, then1.2.11–1.2.20— the third component never resetsCause. The two formats number these blocks by different routes. LaTeX uses its own
blocktcolorbox counter, declarednumber within=section; since each handout is emitted as a\section, the counter resets per handout. HTML uses the@serialstamped during assembly. In the assemblyserial-stamppass, the$b-terminaltest — 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. Usingsections in place of handouts avoids the bug precisely becausesectionwas in the test.Origin. The
$b-terminalpredicate 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-terminaltest, so each opens its own scope and its blocks restart, matching the print output.Testing. A synthetic two-handout document now numbers
1.2.1–1.2.3in 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