How to transform all math.cases with its children to be in math.display mode?

How to transform all math.cases with its children to be in math.diaplay mode?

I tried

#show math.cases: it => it.children.map(x => math.display(x)).join(linebreak())

but now the big left brace is missing.

You can draw a left brace using $lr(\{ ... )$ and you can stack the children vertically using mat or using stack, I think. The former is probably better since it preserves alignment points (&) as a feature.

I think just mat works out well and it looks pretty good. Spacing can probably be further tweaked

#let eq = $R = cases(&x &+& z & "if A", sum_(i=1)^(N)&x_i &+& z_i & "if B")$
#eq

#show math.cases: math.display
Just `display()`\
#eq


#show math.cases: it => {
  math.mat(gap: it.gap, delim: (it.delim.at(0), none), ..it.children.map(x => (math.display(x), )), align: left)
}

With `mat()`\
#eq

image

1 Like

Maybe defining another cases is easier and robuster?

#let dcases(..args) = math.cases(..args.pos().map(math.display), ..args.named())
$
  dcases(
    nabla dot vb(D) &= 4 pi rho_"f ",
    nabla dot vb(B) &= 0,
    nabla times vb(E) &= - 1 / c pdv(, t) vb(B),
    nabla times vb(H) &= (4pi) / c vb(J)_"f " +1 / c pdv(, t) vb(D)
  )
$

Ref: How to use display style in cases? | Typst Chinese Community (in Chinese)

4 Likes

Hi @Malus_Komarovii, don’t forget to tick :ballot_box_with_check: one of the responses if you got a satisfying answer. The answer you choose should usually be the response that you found most correct/helpful/comprehensive for the question you asked. Thanks!