mirror of
https://github.com/typst/typst
synced 2025-05-15 09:35:28 +08:00
parent
fa42a26f6f
commit
c5e82b3fa8
@ -124,13 +124,25 @@ pub struct LimitsElem {
|
|||||||
/// The base to attach the limits to.
|
/// The base to attach the limits to.
|
||||||
#[required]
|
#[required]
|
||||||
pub body: Content,
|
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 {
|
impl LayoutMath for LimitsElem {
|
||||||
#[tracing::instrument(skip(ctx))]
|
#[tracing::instrument(skip(ctx))]
|
||||||
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
|
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
|
||||||
let mut fragment = ctx.layout_fragment(&self.body())?;
|
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);
|
ctx.push(fragment);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
@ -97,5 +97,6 @@ $ attach(A, t: #locate(it => oops)) $
|
|||||||
#let eq = $ ∫_a^b iota_a^b $
|
#let eq = $ ∫_a^b iota_a^b $
|
||||||
#eq
|
#eq
|
||||||
#show "∫": math.limits
|
#show "∫": math.limits
|
||||||
#show math.iota: math.limits
|
#show math.iota: math.limits.with(inline: false)
|
||||||
#eq
|
#eq
|
||||||
|
$iota_a^b$
|
||||||
|
Loading…
x
Reference in New Issue
Block a user