Use something like math.attach() in text mode?

The current situation is not ideal and will probably change in the future. One of the difficulties is that it’s often not clear what should be typeset with a math font (which can include seperate glyphs for upright, italic, sans serif…) and what should be typeset with the text font (which can look different from the upright math font).

Anyway currently, to use the characters from the math font you can do this:

$
  attach(
    upright(O),
    tl: sans("xyz"),
    bl: upright("abc"),
    tr: italic("sample"),
    br: upright("VSMOW"),
  )
$

image

And to use the text font (and the monospace font for sans serif), as described in this issue on GitHub you can define a helper function to include normal text elements in math mode:

#let mtext = text.with(font: "Libertinus Serif")

$
  attach(
    upright(O),
    tl: #`xyz`,
    bl: #mtext[abc],
    tr: #mtext[_sample_],
    br: #mtext[VSMOW],
  )
$

image

Note a related change in Typts 0.13 (the next release): single letter words written in double quotes (for example "a") will be typeset with the upright math instead of italic math font, i.e. single letter words will be treated the same as multi-letter words.

1 Like