diff --git a/crates/typst-library/src/math/mod.rs b/crates/typst-library/src/math/mod.rs index 0429265f..f1676b91 100644 --- a/crates/typst-library/src/math/mod.rs +++ b/crates/typst-library/src/math/mod.rs @@ -47,6 +47,7 @@ use crate::meta::{ Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable, }; use crate::prelude::*; +use crate::shared::BehavedBuilder; use crate::text::{ families, variant, FontFamily, FontList, LinebreakElem, SpaceElem, TextElem, TextSize, }; @@ -414,7 +415,11 @@ impl LayoutMath for Content { } if let Some(children) = self.to_sequence() { + let mut bb = BehavedBuilder::new(); for child in children { + bb.push(child.clone(), StyleChain::default()); + } + for (child, _) in bb.finish().0.iter() { child.layout_math(ctx)?; } return Ok(()); diff --git a/crates/typst-library/src/math/op.rs b/crates/typst-library/src/math/op.rs index 8ad74c49..d2c62452 100644 --- a/crates/typst-library/src/math/op.rs +++ b/crates/typst-library/src/math/op.rs @@ -60,7 +60,7 @@ macro_rules! ops { );)* let dif = |d| { - HElem::new(THIN.into()).pack() + HElem::new(THIN.into()).with_weak(true).pack() + MathStyleElem::new(TextElem::packed(d)).with_italic(Some(false)).pack() }; math.define("dif", dif('d')); diff --git a/tests/ref/math/frac.png b/tests/ref/math/frac.png index 80327578..adb9ad0c 100644 Binary files a/tests/ref/math/frac.png and b/tests/ref/math/frac.png differ diff --git a/tests/typ/math/frac.typ b/tests/typ/math/frac.typ index dc120ec3..f3c31070 100644 --- a/tests/typ/math/frac.typ +++ b/tests/typ/math/frac.typ @@ -20,6 +20,11 @@ $ binom(circle, square) $ // Error: 8-13 missing argument: lower $ binom(x^2) $ +--- +// Test dif. +$ (dif y)/(dif x), dif/x, x/dif, dif/dif \ + frac(dif y, dif x), frac(dif, x), frac(x, dif), frac(dif, dif) $ + --- // Test associativity. $ 1/2/3 = (1/2)/3 = 1/(2/3) $