Files
texrra-engine/scripts/compile-tex-reference.sh
T
gloamxun b7a8637835 Compile a trustworthy TeX reference for fidelity checks
The checked-in template.pdf is stale: its references.bib snapshot does not
match the checked-in .bib, so earlier scores used the wrong oracle. Add a
reproducible pdflatex/bibtex script that copies the fixture, drops the unused
cleveref package (cleveref/hyperref socket mismatch in this TeX Live), defines
languagename for lipsum, and produces a valid 3-page reference. Re-score route-D
against it: 1243 reference words, 1251 candidate words, ratio 0.8605.
2026-10-28 13:35:28 +08:00

36 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Compile the arXiv fixture into a trustworthy TeX Live reference PDF.
#
# The checked-in template.pdf is stale (its references.bib snapshots differ
# from the checked-in .bib). The fixture also loads cleveref but never uses
# \cref, and the current TeX Live cleveref/hyperref socket pair fails; dropping
# that unused package makes the reference reproducible without changing any
# visible content. lipsum's language hook needs \languagename in this TeX Live.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
source_dir=${1:-"$root/fixtures/arxiv-template"}
out=${2:-/tmp/texrra-arxiv-reference}
rm -rf "$out"
mkdir -p "$out"
cp "$source_dir"/template.tex "$source_dir"/references.bib \
"$source_dir"/arxiv.sty "$source_dir"/orcid.pdf "$out"/
sed -i '/\\usepackage{cleveref}/d' "$out/template.tex"
cd "$out"
for pass in 1 2 3; do
pdflatex -interaction=nonstopmode \
'\def\languagename{english}\input{template.tex}' \
>"pass-$pass.log" 2>&1
if [ "$pass" -eq 1 ]; then
bibtex template >bibtex.log 2>&1
fi
done
if grep -q '^!' template.log; then
echo "TeX reference still has errors; see $out/template.log" >&2
exit 1
fi
echo "$out/template.pdf"