summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/math/mod.rs6
-rw-r--r--src/doc.rs5
-rw-r--r--tests/ref/math/content.pngbin6731 -> 7871 bytes
-rw-r--r--tests/typ/math/content.typ6
4 files changed, 13 insertions, 4 deletions
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 85bf56ca..76dcdc2e 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 47bdb23d..9fbd9436 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 3476dbc4..46d5ef9b 100644
--- a/tests/ref/math/content.png
+++ b/tests/ref/math/content.png
Binary files differ
diff --git a/tests/typ/math/content.typ b/tests/typ/math/content.typ
index b33873d5..dc0ec85c 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])