Files
texrra-engine/docs/TEX_FIDELITY_BENCHMARK.md
T

1.9 KiB
Executable File

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.

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:

reference_pages 3, candidate_pages 3
reference_words 1246, candidate_words 1251
word_sequence_ratio 0.8514
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.

Line-break residual

The 2.1 paragraph still takes seven lines in route-D while TeX takes six. A debug run of the clause breaker found that the line ending at facilisi. is a feasible candidate (natural=31562413, target=30785864, shrink=805030, badness=90), but the global path still chooses seven lines. Raising tolerance or line_penalty did not change the chosen break set. Instrumenting the final candidate table showed only (lines=7, cost=2348) for this paragraph, so a six-line path is not reachable under the current Times metrics; further glue/penalty tuning cannot fix it. The remaining work is metric parity (word and script widths) plus the formula body.