r"""Write paper/tables/fallbacks.tex: \providecommand for number macros used in the text but not (yet) generated.""" import glob, os, re ROOT = os.path.join(os.path.dirname(__file__), "..") defined = set(re.findall(r"\\newcommand\{\\([A-Za-z]+)\}", open(os.path.join(ROOT, "paper/tables/numbers.tex")).read())) used = set() for f in glob.glob(os.path.join(ROOT, "paper/sections/*.tex")) + glob.glob(os.path.join(ROOT, "paper/appendix/*.tex")): txt = open(f).read() used |= set(re.findall(r"\\([A-Z][A-Za-z]+)(?![A-Za-z])", txt)) used |= set(re.findall(r"\\((?:betaHigh|rHA|rTC|wL|wH|rr|rBase|rPeak)[A-Za-z]*)(?![A-Za-z])", txt)) std = {"CEU", "CEUt", "E", "R", "Qt", "FloatBarrier", "Big", "Alph", "LARGE", "Omega", "Large", "Huge", "Roman"} missing = sorted(u for u in used - defined - std if not u.startswith("WP")) with open(os.path.join(ROOT, "paper/tables/fallbacks.tex"), "w") as fh: fh.write("% fallbacks for macros not yet generated (empty in the final version)\n") for m in missing: fh.write(f"\\providecommand{{\\{m}}}{{??}}\n") print("missing macros:", missing)