summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-05-29 15:17:05 +0200
committerGitHub <noreply@github.com>2024-05-29 13:17:05 +0000
commite6739ecc2f78f023b7b6b1729983af30f657e6dd (patch)
tree7d8a72bfc0e968e4c672f6ae50e41119cdbf20c3 /crates
parent06433bc95f9ca6d26ced8dc35cb2ecc5da3082dc (diff)
Fix figure centering (#4276)
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/model/figure.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/typst/src/model/figure.rs b/crates/typst/src/model/figure.rs
index 30708711..a21e5af5 100644
--- a/crates/typst/src/model/figure.rs
+++ b/crates/typst/src/model/figure.rs
@@ -14,8 +14,8 @@ use crate::introspection::{
Count, Counter, CounterKey, CounterUpdate, Locatable, Location,
};
use crate::layout::{
- Alignment, BlockElem, Em, HAlignment, Length, OuterVAlignment, PlaceElem, VAlignment,
- VElem,
+ AlignElem, Alignment, BlockElem, Em, HAlignment, Length, OuterVAlignment, PlaceElem,
+ VAlignment, VElem,
};
use crate::model::{Numbering, NumberingPattern, Outlinable, Refable, Supplement};
use crate::text::{Lang, Region, TextElem};
@@ -317,11 +317,7 @@ impl Show for Packed<FigureElem> {
}
// Wrap the contents in a block.
- realized = BlockElem::new()
- .with_body(Some(realized))
- .pack()
- .spanned(self.span())
- .aligned(Alignment::CENTER);
+ realized = BlockElem::new().with_body(Some(realized)).pack().spanned(self.span());
// Wrap in a float.
if let Some(align) = self.placement(styles) {
@@ -340,7 +336,10 @@ impl ShowSet for Packed<FigureElem> {
fn show_set(&self, _: StyleChain) -> Styles {
// Still allows breakable figures with
// `show figure: set block(breakable: true)`.
- BlockElem::set_breakable(false).wrap().into()
+ let mut map = Styles::new();
+ map.set(BlockElem::set_breakable(false));
+ map.set(AlignElem::set_alignment(Alignment::CENTER));
+ map
}
}