Keep the last bibliography unit after the title spacer

The title spacer was inserted into base_units, but the paragraph/unit zip only
consumed paragraphs.len() units, silently dropping the final bibliography entry
(the third reference). Push the spacer directly into units and zip paragraphs
with the remaining base units instead.

Verified all three arXiv references are present again in the 3-page PDF; test
count stays 1073.
This commit is contained in:
gloamxun committed 2026-10-27 22:42:09 +08:00
1 parent a084845184
commit 5c281d70cc
1 file changed
+6 -7
+6 -7
View File
@@ -14034,15 +14034,14 @@ fn build_document_with_labels(
base_units[index].space_shrink += below_display.2; base_units[index].space_shrink += below_display.2;
} }
} }
if has_title_bars(geometry) { let title_spacer = has_title_bars(geometry).then(|| Unit::rule(u64::MAX, 0, 2 * SCALE));
// The class's title block starts with a top rule and vskip. The page let mut units: Vec<Unit> =
// builder discards glue before the first unit, so use an invisible Vec::with_capacity(base_units.len() + usize::from(title_spacer.is_some()));
// rule as the spacer instead.
base_units.insert(0, Unit::rule(u64::MAX, 0, 2 * SCALE));
}
let mut units: Vec<Unit> = Vec::with_capacity(base_units.len());
let mut unit_for_paragraph = Vec::with_capacity(paragraphs.len()); let mut unit_for_paragraph = Vec::with_capacity(paragraphs.len());
let mut footnote_count = 0usize; let mut footnote_count = 0usize;
if let Some(spacer) = title_spacer {
units.push(spacer);
}
for (paragraph, unit) in paragraphs.iter().zip(base_units) { for (paragraph, unit) in paragraphs.iter().zip(base_units) {
unit_for_paragraph.push(units.len()); unit_for_paragraph.push(units.len());
units.push(unit); units.push(unit);