The .tex is no longer stale: regenerated from the canonical .md by build_tex.py (pandoc 3.1.3 + pdflatex on the server; marked GENERATED, never edited by hand). PDF: 28 pages, 0 errors, 0 undefined references, 0 overfull boxes. For LaTeX the .md got braces on four n_\max subscripts (fix_md_for_latex.py; rendering identical) and Table 10 was split into totals (10) and per-problem counts (10b) so that it fits a page; numbers unchanged. verify_article on the server 467 OK / 0 BAD; regression x2 1226 passed, 0 failed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Make the math of article/sim_numerics.md valid LaTeX as well as MathJax: a sub- or
|
||||
superscript that starts with a bare control word (n_\\max) needs braces in LaTeX (n_{\\max}).
|
||||
The rendered formula is identical. Reports what it finds; --apply writes.
|
||||
|
||||
python -u fix_md_for_latex.py [--apply]
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
PATH = "article/sim_numerics.md"
|
||||
# only argument-less control words (n_\max); a macro with an argument (x_\mathrm{far},
|
||||
# r_\text{new}) is valid LaTeX as written, and bracing it would detach its argument
|
||||
PAT = re.compile(r"([_^])(\\[A-Za-z]+)(?![A-Za-z{])")
|
||||
|
||||
|
||||
def main():
|
||||
with open(PATH, encoding="utf8") as fh:
|
||||
text = fh.read()
|
||||
hits = PAT.findall(text)
|
||||
print(f"{len(hits)} bare control words in sub/superscripts:", sorted(set(h[1] for h in hits)))
|
||||
if "--apply" in sys.argv:
|
||||
text = PAT.sub(lambda m: f"{m.group(1)}{{{m.group(2)}}}", text)
|
||||
with open(PATH, "w", encoding="utf8") as fh:
|
||||
fh.write(text)
|
||||
print("braced")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user