"""Rebuild the standalone PDF with pdflatex; no network calls or prior archive.""" from pathlib import Path import shutil import subprocess import sys root=Path(__file__).resolve().parent folder=root/'manuscript' engine=shutil.which('pdflatex') if not engine: raise SystemExit('pdflatex is required to rebuild the PDF, but not to run the research code.') for _ in range(3): result=subprocess.run([engine,'-interaction=nonstopmode','-halt-on-error', 'VELORYN_Manuscript.tex'],cwd=folder, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) if result.returncode: print(result.stdout,file=sys.stderr) raise SystemExit(result.returncode) log=(folder/'VELORYN_Manuscript.log').read_text(errors='replace') if 'There were undefined references' in log or 'Overfull \\hbox' in log: print('PDF built, but inspect the LaTeX log for unresolved references or line overflow.',file=sys.stderr) print(folder/'VELORYN_Manuscript.pdf')