#!/usr/bin/env python3 """Check the plain-text Supporting Information references in main.tex against supplement.aux. Geophysical Prospecting asks for basic LaTeX without cross-document references, so main.tex writes "Section~S6.1", "Table~S9", ... as text. This script maps each of them to the label it stands for, reads the numbers that supplement.tex actually produced, and fails if any differ or if main.tex uses an SI reference that is not in the map. Run after building supplement.tex: python3 check_si_refs.py """ import re import sys # text in main.tex -> label in ../paper/sections/ MAP = { "Section~S2": "sec:related", "Table~S1": "tab:positioning", "Table~S2": "tab:audit", "Section~S3.2": "sec:data:d2", "Table~S3": "tab:package", "Table~S4": "tab:methods", "Section~S4.5": "sec:method:rml", "Appendix~SA": "app:proofs", "Appendix~SB": "app:field", "Appendix~SC": "app:record", "Proposition~S1": "prop:blur", "Proposition~S2": "prop:ident", "Proposition~S3": "prop:tie", "Proposition~S4": "prop:bank", "Proposition~S6": "prop:reference", "Corollary~S3": "cor:twomode", "Corollary~S4": "cor:tolerance", "Section~S6.1": "sec:exp:p2", "Table~S9": "tab:h2a", "Table~S10": "tab:sigmaa", "Section~S6.3": "sec:exp:p2r", "Section~S6.4": "sec:exp:mech", "Table~S13": "tab:benchdesign", "Table~S14": "tab:benchverdicts", "Table~S15": "tab:s2", "Table~S17": "tab:t3", "Section~S7": "sec:discussion", "Table~S19": "tab:lessons", "Corollary~S1": "cor:band", "Proposition~S5": "prop:coverage", "Lemma~S2": "lem:sandwich", "Section~SC.5": "app:record:gp", "Table~S7": "tab:h1", "Table~S27": "tab:bandspectra", } aux = open("supplement.aux", encoding="utf-8").read() labels = {m.group(1): m.group(2) for m in re.finditer(r"\\newlabel\{([^}]*)\}\{\{([^}]*)\}", aux)} text = re.sub(r"(?