From 5c281d70ccf02b0286c75f60fed23fb89030fc42 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 27 Oct 2026 22:42:09 +0800 Subject: [PATCH] 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. --- src/route_d.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/route_d.rs b/src/route_d.rs index 20a6807..2bb378a 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -14034,15 +14034,14 @@ fn build_document_with_labels( base_units[index].space_shrink += below_display.2; } } - if has_title_bars(geometry) { - // The class's title block starts with a top rule and vskip. The page - // builder discards glue before the first unit, so use an invisible - // rule as the spacer instead. - base_units.insert(0, Unit::rule(u64::MAX, 0, 2 * SCALE)); - } - let mut units: Vec = Vec::with_capacity(base_units.len()); + let title_spacer = has_title_bars(geometry).then(|| Unit::rule(u64::MAX, 0, 2 * SCALE)); + let mut units: Vec = + Vec::with_capacity(base_units.len() + usize::from(title_spacer.is_some())); let mut unit_for_paragraph = Vec::with_capacity(paragraphs.len()); let mut footnote_count = 0usize; + if let Some(spacer) = title_spacer { + units.push(spacer); + } for (paragraph, unit) in paragraphs.iter().zip(base_units) { unit_for_paragraph.push(units.len()); units.push(unit);