Defer bottom floats like TeX page building

This commit is contained in:
gloamxun committed 2026-10-23 23:48:28 +08:00
1 parent 17638996a1
commit 4dd28b3aa7
6 files changed
+66 -34

No files matched your search

+13 -14
View File
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
PDF opt-in with `?engine=route-d`). 461 workspace tests are green and no oracle
PDF opt-in with `?engine=route-d`). 462 workspace tests are green and no oracle
fixture is ignored.
Known gaps, in dependency order:
@@ -249,16 +249,14 @@ breaks; at `\tolerance=10000` the wide-measure fixture now matches pdfLaTeX at
breaks because the demerits optimum differs; that stays documented as a
known approximation.
Bottom floats now have their own page fixture: when the float fits, the
body break matches pdfLaTeX. When it does not fit the remaining body space,
the paged builder ends the current page and defers the float, while TeX
keeps filling the page before placing the float on the next one; that
deferral-fill case stays documented as a known approximation.
`PageBuilder::build_with_deferred_bottom_floats` now implements TeX's
behaviour for that case: the current page keeps filling, the float is
carried to the next page's bottom, and a float larger than the page still
ends the page rather than looping. The route-D service still calls `build`,
so endpoint behaviour is unchanged until that wiring lands.
Bottom floats have two page fixtures: one where the float fits, and one
where it does not fit the remaining body space. In both cases the page
count and per-page text match pdfLaTeX: the page keeps filling, and a
float that cannot fit is carried to the next page's bottom, exactly as
TeX's page builder does. `PageBuilder::build_with_deferred_bottom_floats`
implements that behaviour, `Engine::layout_paged` and the route-D service
use it, and a float taller than a page still ends the page rather than
looping.
### P2 — Vertical list, page builder, `\output` (L2)
@@ -318,11 +316,12 @@ interpreter past the shipout/ifdim/ifnum/ifodd/ifcase subset.
Acceptance: 10 page fixtures (article text, footnotes, floats, forced breaks);
page counts identical and first/last baselines within 1pt of pdfLaTeX.
Progress: nine page fixtures are wired (single-line paragraphs, `\parskip=6pt`
Progress: ten page fixtures are wired (single-line paragraphs, `\parskip=6pt`
spacing, multi-line paragraphs split across pages, a 300pt `\textheight`, a
30pt `\topskip`, `\newpage` forced breaks, stretchy `\vskip` glue between
paragraphs, `\footnotetext` insertions reserved at the page bottom, and a
`[t]` float that reserves its height plus `\textfloatsep` on its own page); each
paragraphs, `\footnotetext` insertions reserved at the page bottom, a
`[t]` float that reserves its height plus `\textfloatsep` on its own page,
and `[b]` floats that fit or defer to the next page); each
asserts the same page count and the same per-page body text as pdfLaTeX, with
footnote text excluded from the body comparison. Route-D's source mapping still
does not raise LaTeX floats, so the float fixture drives `Engine` directly.