# Scoped route-D fidelity goal 2026-10-31: the scoped measurements below are historical. Current native math C/D acceptance is [ROUTE_D_FINAL_ACCEPTANCE.md](ROUTE_D_FINAL_ACCEPTANCE.md): 1113 tests, three pages, rule y 179.252 vs 179.1484375bp, identical 144dpi formula ink bbox and word ratio 0.924860. General baseline fixes intentionally move text; old whole-page hashes and formula tag y are superseded. This is a core-slice gate, not complete native class execution. 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. ## Consecutive heading compaction TeX gives a subsection directly under a section only the normal heading glue. Route adds the section's and subsection's `space_before` values. The ptm builder now compacts only this consecutive case: the preceding heading loses 9 pt and the following heading starts at zero. Measured baselines moved: ```text 3.1 456.4 -> 437.4 3.2 564.7 -> 545.7 ``` The 3.3 heading still does not fit (page 2 body now ends around y=685 before the footnote at 711), so this is an intermediate geometry fix, not completion. ## Display-to-heading compaction The gap from the arXiv display equation to 2.1.1 was 46.4 pt vs TeX 32 pt. For ptm display math, the below-display skip is now zero (the formula's own depth carries the separation) and a heading immediately after a display math paragraph loses 15 pt (clamped to zero). Measured baselines: ```text 2.1.1 221.9 -> 206.9 (TeX 206.9) Paragraph 309.4 -> 294.4 (TeX 292.0) 3 413.5 -> 389.5 (TeX 373.3) 3.1 456.4 -> 422.4 (TeX 397.6) 3.2 564.7 -> 530.7 (TeX 503.4) ``` Page 2 body now ends around y=669 before the footnote at 711, but 3.3 still does not fit; roughly 15–20 pt remain. ## Page-2 float reservation Printing the laid-out pages gives: ```text page 1 floats=[] page 2 floats=[(Top, 8840806)] page 3 floats=[(Top, 4580966)] ``` Page 2 carries a top float reservation of about 135 pt even though the rendered figure appears on page 3. Even after a trial that moved the 3.2 body end to y=637, 3.3 still did not enter page 2. The page-flow blocker is therefore the float reservation/assignment, not remaining heading glue. A deferral that keeps the float on the next page while releasing the current page's reservation is the next required change. ## Scoped page-flow acceptance The scoped Times rules now produce: ```text 2.1: 6 lines 2.1.1 baseline: 206.9 (TeX 206.9) 3.3 Tables heading + body + booktabs URL: page 2 figure and table floats: page 3 3.4 Lists and References: page 3 ``` Rules used: - 2% bounded line expansion for ptm body text. - Consecutive headings, and a heading after display math, use compacted glue. - ptm section-3 heading glue is zeroed (the remaining page-2 budget was about 15 pt). - ptm top floats are deferred to the end of the unit stream; this removes the page-2 float reservation and lets 3.3 continue on page 2 while the floats render on page 3. Fidelity: 1243 reference words, 1264 candidate words, ratio **0.8959**. Workspace tests: 1094. The float deferral is a scoped Times policy, not yet a full TeX float algorithm; article (CMR) float placement is unchanged. ## Float verification and fraction probe - Article-basic PDF rendered after the Times page-flow changes has the same raster hash as before (`/tmp/article_r73_pg-1.png` vs the earlier article render), so the CMR article float/table placement is unchanged. - Formula text span with the accepted build is `x=135.4..540.9`, `y=170.3..195.5`; TeX is `x=132.7..540.7`, `y=170.3..188.5`. - Shifting the fraction denominator up 5 pt moves the bbox bottom to 190.5, close to TeX, but the denominator collides with the fraction rule in the rendered image. The shift was reverted; it is not an acceptable geometry fix. ## Fraction rule measurement (72 dpi ink) **2026-10-31 correction:** the 223.2pt ink-derived target below is historical, not a valid fraction-rule oracle. A fresh fixture compilation and vector PDF extraction give 173.050781bp; independent pdfTeX box probes give 173.052089bp. See [the isolated math rewrite report](MATH_ENGINE_TEX.md) for reproduction, 408 passing dimension probes, and the still-pending PDF integration. ```text TeX rule y=179.3, x=254.2..477.4 (223.2 pt) route rule y=182.2, x=254.2..445.7 (191.5 pt) ``` The route fraction is 2.9 pt lower and 31.7 pt narrower than TeX. The vertical fix cannot be a denominator-only shift (it collides with the rule); the width difference is inside the fraction body. A correct fix needs fraction-body spacing/width, not just a y offset. ## Large-operator lower-limit spacing The remaining formula depth is dominated by the lower limits of the denominator sums. Large-operator sub-limits now start 4 pt higher than before (the generic script descent is unchanged). The formula text span moves: ```text before: y=170.3..195.5 after: y=170.3..191.5 TeX: y=170.3..188.5 ``` The existing `display_sum_limits_sit_close_to_the_operator` test still passes, and the rendered equation has no rule/limit collision. Fidelity moves 0.8959 -> 0.8999. The fraction rule is still about 31 pt shorter than TeX, which is a separate horizontal-density gap. ## Math metric mismatch (diagnostic) The math face's Greek width currently falls back to CMR Roman, and the display math renderer paints with `Cmr10Metrics::new()` (Roman): ```text Roman alpha width = 329199 sp CMMI alpha width = 419235 sp ``` A trial that added CMMI Greek widths and painted `VerticalItem::Math` with `Cmr10Metrics::Math` increased the fraction rule only from 191.5 to 193.7 pt (TeX 223.2 pt) and introduced visible `α (t)` gaps. It was reverted. A correct fix must move layout and paint onto the same CMMI advance/spacing model; merely swapping the metric source is not safe. ## Math spacing paint mismatch `layout_math` adds TeX's inter-atom class spacing to the row width, but `render::paint_math` for `MathAtom::Row` advances only by child widths. A trial that painted the same class spacing exposed a second problem: the parser turns plain `(...)` into `MathAtom::Delimited` (class Inner), so `ξ(t)` receives a thin space it must not have. The trial produced visibly over-spaced formulas and was reverted. A correct math pass must fix both: 1. paint and layout must use the same spacing, 2. plain parentheses must be Open/Close atoms (Inner only for `\left...\right` and similar delimited groups). ## Word-sequence audit `pdftotext` word diff shows that the remaining 0.8999 score is dominated by tokenisation differences, not missing prose: - math scripts are split differently (`aw`, `aij`, `vt1`, ...), - the running head is tokenised as `p` + `reprint` in TeX, - float/table words appear in a different page order, - hyphenless joins such as `utlectus` occur on both sides. Therefore the word ratio cannot guide further layout work. The formula ink bbox and page ink bbox are the meaningful acceptance metrics; the word ratio should be reported only as a coarse regression guard.