typst

Set font in equation for a single equation in typst


I know you can use

#show math.equation: set text(font: "Fira Math")

to affect all equations, but I just want to affect a single equation, can I change the font without using show?

For example using emptyset $emptyset$ uses math font, but I want to use the Fira Math font, only for this equation, and not for the rest, is show really required?

For example #text(font:"Fira Math")[$emptyset$] Doesn't work.

I want to rename the $emptyset$ into something like

#{
show math.equation: set text(font: "Fira Math")
[$emptyset$]
}

But I am not very successful.


Solution

  • What you wrote is the correct approach: a scoped show-set rule. If you have to reuse this pattern frequently, you can always define a helper function:

    #let fonted-math(font: "Fira Math", body) = {
      show math.text: set text(font: font)
      body
    }
    
    #fonted-math[$emptyset$]
    $emptyset$
    

    enter image description here