Add float placement and page headers/footers

This commit is contained in:
gloamxun committed 2026-10-19 13:41:29 +08:00
1 parent 1da46c61d6
commit ed1da06685
16 files changed
+974 -90

No files matched your search

+26 -18
View File
@@ -5,26 +5,34 @@ are still missing. Each item names the files/functions to touch.
Completed: paragraph indentation (`\parindent`) and `\hfill`/`\hfil`; sans
family and true scaled small caps; inline box geometry (`\fbox`, `\makebox`,
`\raisebox`), `\minipage`, `\vbox`/`\vtop` block approximations, and
footnotes/`\thanks` (see `docs/STATUS.md`).
`\raisebox`), `\minipage`, `\vbox`/`\vtop` block approximations;
footnotes/`\thanks`; figure/table `[htbp]` placement approximations; and page
styles (plain/fancy, `\thispagestyle`, fancyhdr headers/footers, `\thepage`).
## 1. Floats
- Classify figure/table blocks as floats with `[htbp]` placement hints.
- Planner: maintain pending floats and try top/bottom/page placements; keep
reading order for text and defer floats when they do not fit.
- Renderer: place deferred floats at the saved slots; page keys must include
float placement decisions.
## 2. Page styles / headers-footers
- `DocumentModel` fields for header/footer runs and `\pagestyle`/`\thispagestyle`.
- Paint headers/footers in the page margins in both PDF and SVG; page numbers
need a page index placeholder resolved at paint time.
## 3. Unified pagination
## 1. Unified pagination
- Extract the current duplicated planner (`build_page_break_plan`) and renderer
(`build_positioned_pages`) vertical logic into one page builder returning an
ordered list of placed items, then use it for both page-break decisions and
final painting.
final painting. This is the prerequisite for a true deferred float queue.
## 2. Lengths and base font size
- Emit geometry changes into named length registers so `\textwidth`,
`\textheight`, `\linewidth`, and `\columnwidth` track `\geometry` and
paper-size options instead of fixed A4 defaults.
- Thread the `10pt`/`11pt`/`12pt` class option through the parser, line metrics,
headings, and the PDF so the base size changes consistently.
## 3. Table of contents and lists
- Record section/figure/table entries while parsing, then generate
`\tableofcontents`, `\listoffigures`, and `\listoftables` blocks with
resolved page numbers after pagination.
## 4. PDF painting and title blocks
- Paint rules and frames as native PDF rectangles (`printpdf` operators)
instead of 1x1 image XObjects.
- Let a document-level `\renewcommand{\maketitle}` contribute a real title
block once the engine's title model can run box material.