Add a reproducible TeX fidelity benchmark

Add scripts/tex-fidelity.py: page count, normalized word-sequence similarity and
per-page ink bounds from a 72 dpi grayscale render, using only the stdlib and
Poppler. Document the current arXiv score (0.848 word ratio, 3 pages) and its
limits.

Test count stays 1078.
This commit is contained in:
gloamxun committed 2026-10-28 00:50:37 +08:00
1 parent d5de8b9fe6
commit eb2cb561bd
2 files changed
+178

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
# TeX fidelity benchmark
`scripts/tex-fidelity.py` compares a TeX Live PDF with the route-D PDF using
only Python's standard library and the Poppler commands already used by the
release checks.
```bash
python3 scripts/tex-fidelity.py \
--reference a_template_for_the_arxiv_texlive.pdf \
--candidate a_template_for_the_arxiv_route_d_fixed.pdf \
--json /tmp/fidelity.json
```
It reports:
- page count on both sides
- word count and word-sequence similarity
- per-page ink bounding box and ink fraction (72 dpi grayscale render)
The current arXiv template comparison reports:
```text
reference_pages 3, candidate_pages 3
reference_words 1246, candidate_words 1254
word_sequence_ratio 0.848
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
```
The score is intentionally coarse. It catches lost text, wrong page counts and
large frame shifts; it does not prove glyph-level or baseline-level equality.
Use it together with the side-by-side PDF comparison, not instead of it.