# Scoped route-D fidelity goal Start baseline: engine `c6743e2`, 1089 tests, fidelity 0.8944 against `/tmp/texrra-arxiv-reference/template.pdf` (freshly compiled), warm preview 32–50 ms. ## Scope 1. **Page 2/3 flow** — implement a bounded microtype-like text-width expansion/line-fit model for Times body text so 2.1 is six lines and `3.3 Tables` returns to the bottom of page 2. 2. **Display-math internal geometry** — fraction density and sum/script vertical spacing, checked with the arXiv equation bbox. 3. **Float placement** — verify the arXiv and article samples without regressing the Times table column fix. ## Acceptance - 2.1 paragraph: six lines. - `3.3 Tables` on page 2. - Page ink bbox no regression; page 3 right edge 540. - Formula tag `y≈174.9`, formula text span close to `x=132.7..540.7`. - At least 1089 tests; warm arXiv preview under 100 ms. - Fresh TeX-vs-route comparison and fidelity score in the final report. ## Rejected approaches - Vertical glue/space_before swaps: moved sections but never fit 3.3 and lowered the fidelity score. - Uniform 1%/3% body font shrink (9.9/9.7 pt): 3.3 stayed on page 3. - Uniform 3 pt spaces between every top-level math atom: visually over-spaced. ## Planned model A line-level bounded expansion model: allow a small, symmetric glyph-width expansion window during line breaking (microtype-like), record the chosen expansion per line, and apply the same factor when painting PDF/SVG text. This keeps line targets and glyph advances consistent instead of adding overflow or collapsing interword glue. ## First result - Added `ParagraphStyle.line_expansion` (thousandths), per-line `line_scales` on `Paragraph`, and renderer x-advance compression. - Times text uses a 2% expansion window. The 2.1 paragraph is now **six lines** (was seven). Text still renders with visible word spaces. - `3.3 Tables` remains on page 3. The reason is now localized in the page builder: a top float that does not fit flushes the current page at `VerticalItem::Float` instead of deferring only the float, so following text cannot continue on page 2. - Fidelity moved 0.8944 -> 0.8916 because line breaks and `pdftotext` word boundaries changed; this is a geometry/flow tradeoff, not a claimed win. ## Next Defer non-fitting top floats instead of flushing the page, then re-test 3.3. ## Page-2 fit after expansion With the 2% expansion, 2.1 is six lines. Page 2 still ends at 3.2 with the body baseline at y=704 and the footnote at y=711; there is no vertical room for the 3.3 heading. A combined trial of 11 pt body baselineskip plus 8 pt smaller heading space still put 3.3 on page 3, and was reverted. The remaining page-2 shortfall is therefore not just one line: the 3.2 block starts and ends lower than TeX, and the table float ordering puts 3.3 after the floats on page 3. The next change must address float/unit ordering or the whole 3.2 vertical chain, not more expansion. ## Unit-order diagnosis The arXiv document unit order is correct: ```text 27 figure float (Top) 28 3.3 Tables heading 29 "See awesome Table 1." 30 booktabs text 31 URL 32 table float (Top) 33 3.4 Lists ``` `document.page_breaks` is empty. Therefore 3.3 is not being moved by a float unit ordering mistake; page 2 simply has no vertical room after 3.2. Raising the line expansion from 2% to 5% still leaves 3.3 on page 3, so expansion alone cannot close the page-2 gap. ## 3.2 block baselines After the 2% expansion, page-2 heading baselines are: ```text route TeX delta 2.1 69.7 75.1 -5.4 2.1.1 221.9 206.9 +15.0 Paragraph 309.4 292.0 +17.4 3 413.5 373.3 +40.2 3.1 456.4 397.6 +58.8 3.2 564.7 503.4 +61.3 ``` The 3.2 body starts at 589.2 vs TeX 523.5 (+65.7) and ends before the footnote at y=704. The two largest single jumps are `2.1 -> 2.1.1` (+20.4 rather than the TeX 131.8 pt gap) and `3 -> 3.1` (+42.9 rather than 24.3). A trial reducing all ptm heading space by 10 pt still left 3.3 on page 3 and was reverted.