Centre table floats without losing rules or columns

The rule rectangle used width-margin for its right edge, so a centred table
shrank or lost its booktabs rules. Derive the right edge from the last column
offset instead, then centre a table float by shifting its margin. All three
columns and the rules now stay inside the measure.

Test count stays 1074.
This commit is contained in:
gloamxun committed 2026-10-27 23:42:15 +08:00
1 parent aa2f3cb0af
commit 576626fe04
2 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -678,7 +678,7 @@ impl Halign {
let start = rule.start.min(last);
let end = rule.end.min(last).max(start);
let x = self.column_offset(start) + rule.trim_left;
let right = (self.column_offset(end + 1) - rule.trim_right).min(self.width - self.margin);
let right = self.column_offset(end + 1) - rule.trim_right;
(x, (right - x).max(65_536))
}
}
+6 -1
View File
@@ -13762,8 +13762,13 @@ fn build_document_with_labels(
}
if let Some(table) = spec.table {
if let Some((template, source, target)) = geometry.tabular.get(table) {
let table_unit =
let mut table_unit =
tabular_unit(&geometry, index as u64, template, source, *target);
if let Some(VerticalItem::Halign(halign)) = table_unit.items.first_mut()
&& halign.width < width
{
halign.margin += (width - halign.width) / 2;
}
content.extend(table_unit.items);
}
}