arxiv.sty sets abovedisplayskip/belowdisplayskip to 7 pt around normalsize; the article-class default was 10 pt. Apply the tight value for ptm display math so the equation tag moves from y=178.49 to y=175.49 (TeX y=174.9). Add a unit test for the skip tuple; workspace tests are now 1089.
101 lines
4.0 KiB
Markdown
Executable File
101 lines
4.0 KiB
Markdown
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.
|
|
|
|
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 /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
|
|
- 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 1243, candidate_words 1266
|
|
word_sequence_ratio 0.8944
|
|
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.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
|
|
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.
|
|
|
|
|
|
## Display-equation bbox
|
|
|
|
A 72 dpi ink crop of the formula band (excluding the equation tag) currently
|
|
measures:
|
|
|
|
```text
|
|
TeX: x = 132.7..540.7
|
|
route before gap: x = 144.7..540.9
|
|
route after gap: x = 135.4..540.9
|
|
```
|
|
|
|
The route formula now starts within 2.7 pt of TeX horizontally (it was about
|
|
17 pt too far right). The word-sequence score moves 0.8958 -> 0.8944 because
|
|
pdftotext separates the added relation gap; the geometric span is closer. The
|
|
Times display skips also use arxiv.sty's 7 pt value (not article's 10 pt), moving
|
|
the equation tag from y=178.49 to y=175.49; TeX is y=174.9. 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
|
|
(`ξ ( t ) = P ( ... )`), so that approach was reverted.
|
|
|
|
|
|
## Page-2 heading drift and 3.3
|
|
|
|
Baseline positions on page 2 (top of glyph, pt):
|
|
|
|
```text
|
|
TeX route delta
|
|
2.1 75.09 69.74 -5.35
|
|
2.1.1 206.85 227.90 +21.05
|
|
Paragraph 292.01 315.40 +23.39
|
|
3 373.34 419.47 +46.13
|
|
3.1 397.61 462.43 +64.82
|
|
3.2 503.38 570.65 +67.27
|
|
```
|
|
|
|
The drift is cumulative, not a single paragraph-space value. A trial with an
|
|
11 pt body baselineskip reduced the 3.2 delta to about +32 pt, and reducing
|
|
heading space by 8 pt reduced it further, but `3.3 Tables` still did not fit on
|
|
page 2. The remaining cause is route-D's extra body line in the 3.2 paragraph:
|
|
TeX's `microtype` expansion/protrusion lets it fit one more line than the fixed
|
|
Times metrics. Page-2 fit therefore needs a text-expansion model, not more
|
|
`\space_before` tuning.
|