Unable to set the math font once the block font is set

I want to use some san serif font in a text box (block), but this globally affects all blocks including math equations. Adding additional rule results in a warning.

An working example:

#set text(
  font: (
    "XITS",
  ),
  size: 12pt,
)

#show block: set text(font: "Calibri")
#show math.equation: set text(font: "XITS Math")

Some text

$ 5 alpha + 3 beta = gamma $


#block(
  fill: teal.lighten(75%),
  inset: 8pt,
  radius: 4pt,
)[
  some text
]

This code produces a warning and the math font is not properly set in the pdf:

current font is not designed for math
Hint: rendering may be poor

Any suggestions?

I suggest removing #show block: set text(font: "Calibri") and using the following.

#let fancy-block(body) = block(
  fill: teal.lighten(75%),
  inset: 8pt,
  radius: 4pt,
  {
    set text(font: "Calibri")
    body
  }
)
#fancy-block[Some text.]

In general, rules for basic layout elements like block, box, grid should be avoided.

2 Likes

Oh, I see. Thank you for the straightforward answer.

1 Like