Skip to content

Debug: add LaTeX numbering check assertions#2811

Merged
rbeezer merged 4 commits intoPreTeXtBook:masterfrom
rbeezer:latex-number-check-debug
Mar 30, 2026
Merged

Debug: add LaTeX numbering check assertions#2811
rbeezer merged 4 commits intoPreTeXtBook:masterfrom
rbeezer:latex-number-check-debug

Conversation

@rbeezer
Copy link
Copy Markdown
Collaborator

@rbeezer rbeezer commented Mar 30, 2026

Summary

  • Add a debug mechanism (-x debug.numbering.check yes) that embeds PreTeXt-computed numbers into LaTeX source and compares them against LaTeX's own counter values at compile time
  • Separate macros for block elements (\ptxnumbercheck via \thetcbcounter) and divisions (\ptxdivisionnumbercheck via \csname the#2\endcsname)
  • When the flag is false, no macros are defined and nothing is emitted — zero cost

Developing the check mechanism revealed a cross-format formatting bug: subnumbered figure-like elements inside sidebyside panels produced 6.1.(a) instead of 6.1(a). The period separator is now suppressed for these elements. This fix affects all output formats (LaTeX, HTML, etc.) and is a separate commit from the debug infrastructure.

Test results

Configuration Block checks Division checks Mismatches
Sample article 474 237 14 block (all explained)
Sample book — no parts 175 105 0
Sample book — decorative parts 175 105 0
Sample book — structural parts 175 105 0

The 14 article mismatches: 12 from a missing structure-number template for figure/sbsgroup/sidebyside/figure, 1 from openproblem placeholder numbers, 1 from a figure inside decorative exercises. None are introduced by this branch — they are pre-existing bugs surfaced by the check.

Test plan

  • Build sample article and sample book with -x debug.numbering.check yes, confirm warnings match documented mismatches
  • Build without the flag, confirm no new macros or assertions in output
  • Verify HTML output only differs in subnumber formatting (6.1(a) vs 6.1.(a))

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

rbeezer and others added 4 commits March 30, 2026 12:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rbeezer
Copy link
Copy Markdown
Collaborator Author

rbeezer commented Mar 30, 2026

  • Before and after HTML looks good, other than the formatting of subnumbered items.
  • Before and after LaTeX is no change.
  • Before and after LaTeX, with new debugging enabled, looks as expected.
  • PDF compilation, with debugging assertions, indicates two minor bugs that need further investigation.

Note: if the debug flag is not set, nothing is added to the LaTeX source, no macros, no checks.

Code itself looks good.

@rbeezer rbeezer merged commit 923855a into PreTeXtBook:master Mar 30, 2026
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