From f8966f9e867dc72080355342aab64734f70ac4f7 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 19 Apr 2023 10:38:03 +0200 Subject: Fix realize in math --- library/src/math/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'library/src/math/mod.rs') diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs index 97e5548e..9c8a9cdf 100644 --- a/library/src/math/mod.rs +++ b/library/src/math/mod.rs @@ -344,9 +344,18 @@ impl LayoutMath for EquationElem { impl LayoutMath for Content { fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> { + // Directly layout the body of nested equations instead of handling it + // like a normal equation so that things like this work: + // ``` + // #let my = $pi$ + // $ my r^2 $ + // ``` + if let Some(elem) = self.to::() { + return elem.layout_math(ctx); + } + if let Some(realized) = ctx.realize(self)? { - realized.layout_math(ctx)?; - return Ok(()); + return realized.layout_math(ctx); } if let Some(children) = self.to_sequence() { -- cgit v1.2.3