diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 85bf56ca0..76dcdc2ec 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -294,7 +294,11 @@ impl LayoutMath for Content { return node.layout_math(ctx); } - let frame = ctx.layout_content(self)?; + let mut frame = ctx.layout_content(self)?; + if !frame.has_baseline() { + let axis = scaled!(ctx, axis_height); + frame.set_baseline(frame.height() / 2.0 + axis); + } ctx.push(FrameFragment::new(ctx, frame).with_spaced(true)); Ok(()) diff --git a/src/doc.rs b/src/doc.rs index 47bdb23d0..9fbd94367 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -85,6 +85,11 @@ impl Frame { self.baseline.unwrap_or(self.size.y) } + /// Whether the frame has a non-default baseline. + pub fn has_baseline(&mut self) -> bool { + self.baseline.is_some() + } + /// Set the frame's baseline from the top. pub fn set_baseline(&mut self, baseline: Abs) { self.baseline = Some(baseline); diff --git a/tests/ref/math/content.png b/tests/ref/math/content.png index 3476dbc48..46d5ef9b2 100644 Binary files a/tests/ref/math/content.png and b/tests/ref/math/content.png differ diff --git a/tests/typ/math/content.typ b/tests/typ/math/content.typ index b33873d5b..dc0ec85c4 100644 --- a/tests/typ/math/content.typ +++ b/tests/typ/math/content.typ @@ -6,9 +6,9 @@ $ sum_(i=#emoji.apple)^#emoji.apple.red i + monkey/2 $ --- -// Test table above fraction. -$ x := #table(columns: 2)[x][y]/mat(1, 2, 3) $ - +// Test tables. +$ x := #table(columns: 2)[x][y]/mat(1, 2, 3) + = #table[A][B][C] $ --- // Test non-formula math directly in content. #math.attach($a$, top: [b])