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.
This commit is contained in:
gloamxun committed 2026-10-28 13:35:28 +08:00
1 parent b8573a2e70
commit b7a8637835
3 files changed
+53 -8

No files matched your search

+3 -2
View File
@@ -17,7 +17,7 @@ PDF is the best verified build; no unsafe layout experiment was kept.
- Workspace tests: **1084 passed / 0 failed**
- 438 engine / 451 core / 67 server / 71 v1 / 42 oracle / 10 route-D
integration / 4 / 1
- Fidelity harness: 3 vs 3 pages, 1246 vs 1251 words, ratio **0.8514**
- Fidelity harness: 3 vs 3 pages, 1243 vs 1251 words, ratio **0.8605** with a freshly compiled reference
- Formula band ink bbox:
- TeX `x=184..519, y=230..269`
- route-D `x=201..519, y=241..274`
@@ -56,8 +56,9 @@ PDF is the best verified build; no unsafe layout experiment was kept.
```bash
cargo test --workspace --offline
./scripts/compile-tex-reference.sh fixtures/arxiv-template /tmp/texrra-arxiv-reference
python3 scripts/tex-fidelity.py \
--reference a_template_for_the_arxiv_texlive.pdf \
--reference /tmp/texrra-arxiv-reference/template.pdf \
--candidate a_template_for_the_arxiv_route_d_fixed.pdf \
--json /tmp/fidelity.json
```
+15 -6
View File
@@ -4,13 +4,22 @@
only Python's standard library and the Poppler commands already used by the
release checks.
First compile a reference from the checked-in fixture. The checked-in
`fixtures/arxiv-template/template.pdf` is stale (it was built from a different
`references.bib` snapshot), so do not use it as an oracle.
```bash
./scripts/compile-tex-reference.sh fixtures/arxiv-template /tmp/texrra-arxiv-reference
python3 scripts/tex-fidelity.py \
--reference a_template_for_the_arxiv_texlive.pdf \
--reference /tmp/texrra-arxiv-reference/template.pdf \
--candidate a_template_for_the_arxiv_route_d_fixed.pdf \
--json /tmp/fidelity.json
```
The compile script drops the unused `cleveref` package (the fixture never calls
`\cref`; the current TeX Live cleveref/hyperref socket pair fails) and defines
`\languagename` for lipsum. Neither changes visible content.
It reports:
- page count on both sides
@@ -21,12 +30,12 @@ The current arXiv template comparison reports:
```text
reference_pages 3, candidate_pages 3
reference_words 1246, candidate_words 1251
word_sequence_ratio 0.8514
reference_words 1243, candidate_words 1251
word_sequence_ratio 0.8605
page 1 ink bbox: TeX [72, 79, 540, 721] route-D [71, 79, 540, 724]
page 2 ink bbox: TeX [72, 36, 540, 748] route-D [71, 41, 540, 751]
page 3 ink bbox: TeX [72, 36, 540, 748] route-D [71, 41, 540, 751]
page ink fraction: TeX 0.0417/0.0454/0.0432, route-D 0.0428/0.0454/0.0478
page 3 ink bbox: TeX [72, 36, 540, 748] route-D [71, 41, 553, 751]
page ink fraction: TeX 0.0416/0.0448/0.0432, route-D 0.0434/0.0492/0.0434
```
The score is intentionally coarse. It catches lost text, wrong page counts and
@@ -61,4 +70,4 @@ The route formula is about 17 pt narrower and 11 pt lower. The tag itself is
within 1 pt horizontally. The remaining width is in the math body (spacing /
fraction density), not the tag geometry. A trial that inserted 3 pt between every
top-level math atom widened the box but visibly over-spaced the formula
(), so that approach was reverted.
(`ξ ( t ) = P ( ... )`), so that approach was reverted.
+35
View File
@@ -0,0 +1,35 @@
#!/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"