Show page numbers in the table of contents

This commit is contained in:
gloamxun committed 2026-10-25 01:19:10 +08:00
1 parent aaa1ed8213
commit 60281dc9ca
5 files changed
+151 -9

No files matched your search

+21
View File
@@ -927,6 +927,9 @@ pub struct Unit {
/// Shrink of the glue before this unit.
#[serde(default)]
pub space_shrink: i64,
/// For a table-of-contents entry, the unit whose page number it shows.
#[serde(default)]
pub toc_target: Option<UnitId>,
}
impl Unit {
@@ -1044,6 +1047,7 @@ impl Unit {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![VerticalItem::Halign(halign)],
}
}
@@ -1359,6 +1363,7 @@ impl Unit {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
}
}
@@ -1380,6 +1385,7 @@ impl Unit {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
}
}
@@ -1403,6 +1409,7 @@ impl Unit {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
}
}
@@ -1456,6 +1463,7 @@ impl Unit {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
}
}
@@ -4458,6 +4466,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Insertion(Insertion {
class: 0,
@@ -4793,6 +4802,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![VerticalItem::Box(VerticalBox {
width: 10,
height: 10,
@@ -4818,6 +4828,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -4871,6 +4882,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -4938,6 +4950,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -5000,6 +5013,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -5037,6 +5051,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -5746,6 +5761,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -5785,6 +5801,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Box(VerticalBox {
width: 10,
@@ -5821,6 +5838,7 @@ mod tests {
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Float(Float {
gap_before: 0,
@@ -8179,6 +8197,7 @@ b & 2 \\
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
items: vec![
VerticalItem::Float(Float {
placement: FloatPlacement::Top,
@@ -8679,6 +8698,7 @@ b & 2 \\
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
};
let mut document =
Document::new(100, vec![math, Unit::vskip(2, 0), Unit::rule(3, 100, 20)]);
@@ -8834,6 +8854,7 @@ b & 2 \\
space_before: 0,
space_stretch: 0,
space_shrink: 0,
toc_target: None,
};
let mut document = Document::new(800_000, vec![math]);
document.max_depth = 400_000;