Show the current heading in headings-style headers

The headings page style only painted the page number. Document now records its
heading units (unit index and title) during layout, and a page_headings helper
carries the latest heading from page to page through the page sources. The
running-head pass uses that list in headings style: the numbered heading title
is uppercased at the left of the header and the page number stays right-aligned,
with the first page still plain.

The headings test gains a section and checks "1 INTRODUCTION" sits at the left
of the header baseline.
This commit is contained in:
gloamxun committed 2026-10-27 02:44:14 +08:00
1 parent ae810867f7
commit 9da0f136a4
3 files changed
+55 -2

No files matched your search

+4
View File
@@ -1782,6 +1782,9 @@ pub struct Document {
/// Unit indices that start on a fresh page (TeX `\newpage` forced breaks).
#[serde(default)]
pub page_breaks: Vec<usize>,
/// Heading units (unit index, title) in document order, for running heads.
#[serde(default)]
pub headings: Vec<(u64, String)>,
/// TeX `\paperwidth`: width of the output page.
#[serde(default = "default_paper_width")]
pub paper_width: i64,
@@ -1962,6 +1965,7 @@ impl Document {
units,
page_goal,
page_breaks: Vec::new(),
headings: Vec::new(),
paper_width: default_paper_width(),
paper_height: default_paper_height(),
text_width: default_text_width(),