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