Centre raster images inside floats

Add an x offset to VerticalItem::Image and use it when placing a decoded image
in a float, so a 0.4\textwidth plot is centred while its caption remains
centred across the float. Other image uses keep x=0.

Test count stays 1074.
This commit is contained in:
gloamxun committed 2026-10-27 23:37:54 +08:00
1 parent bbedf7676c
commit aa2f3cb0af
4 files changed
+12 -4

No files matched your search

+5
View File
@@ -207,6 +207,9 @@ pub enum VerticalItem {
},
/// A raster image painted into the vertical list.
Image {
/// Horizontal offset inside the float/list.
#[serde(default)]
x: i64,
width: i64,
height: i64,
image: crate::render::RasterImage,
@@ -7924,6 +7927,7 @@ mod tests {
100,
5,
vec![VerticalItem::Image {
x: 0,
width: 100,
height: 30,
image,
@@ -9679,6 +9683,7 @@ b & 2 \\
vec![Unit::vertical(
1,
vec![VerticalItem::Image {
x: 0,
width: 50,
height: 40,
image,