How to force displaystyle in both the numerator and denominator of all fractions?

I used show math.frac: math.display to set a fraction to the display style, but it doesn’t work on

$(sum_(i=1)^n m_i arrow(x)_i) / (sum_(i=1)^n m_i)$

I have to do this

$display(sum_(i=1)^n m_i arrow(x)_i) / display(sum_(i=1)^n m_i)$

to make the sum symbols in display style. But it’s too annoying to add display() when I write many fractions. Is there a more convenient way to achieve this?

You can automate wrapping the numerator and denominator in math.display(/**/) with a show rule:

#show math.frac: math.display
#show math.frac: it => {
  if it.has("label") and it.label == <already-processed> {return it}
  
  [#math.frac(
    math.display(it.num),
    math.display(it.denom)
  )<already-processed>]
}

The label is to stop it from recursing infinitely and hitting the show rule depth limit.

I believe it is visually identical:

1 Like