From c5e82b3fa8e44e0efd9beb37c477e5dc202f523e Mon Sep 17 00:00:00 2001 From: sitandr <60141933+sitandr@users.noreply.github.com> Date: Sat, 24 Jun 2023 15:28:36 +0300 Subject: Added argument to disable limits in inline math, closes #1522 (#1552) --- library/src/math/attach.rs | 14 +++++++++++++- tests/ref/math/attach.png | Bin 29232 -> 28331 bytes tests/typ/math/attach.typ | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/library/src/math/attach.rs b/library/src/math/attach.rs index eee1e80e..340dd21e 100644 --- a/library/src/math/attach.rs +++ b/library/src/math/attach.rs @@ -124,13 +124,25 @@ pub struct LimitsElem { /// The base to attach the limits to. #[required] pub body: Content, + + /// Whether to apply limits in inline equations. + /// + /// It is useful to disable this setting + /// in most cases of applying limits globally + /// (inside show rules or new elements) + #[default(true)] + pub inline: bool, } impl LayoutMath for LimitsElem { #[tracing::instrument(skip(ctx))] fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> { let mut fragment = ctx.layout_fragment(&self.body())?; - fragment.set_limits(Limits::Always); + fragment.set_limits(if self.inline(ctx.styles()) { + Limits::Always + } else { + Limits::Display + }); ctx.push(fragment); Ok(()) } diff --git a/tests/ref/math/attach.png b/tests/ref/math/attach.png index bf63ccce..894f553f 100644 Binary files a/tests/ref/math/attach.png and b/tests/ref/math/attach.png differ diff --git a/tests/typ/math/attach.typ b/tests/typ/math/attach.typ index cb90e5a5..0f404ac7 100644 --- a/tests/typ/math/attach.typ +++ b/tests/typ/math/attach.typ @@ -97,5 +97,6 @@ $ attach(A, t: #locate(it => oops)) $ #let eq = $ ∫_a^b iota_a^b $ #eq #show "∫": math.limits -#show math.iota: math.limits +#show math.iota: math.limits.with(inline: false) #eq +$iota_a^b$ -- cgit v1.2.3