[Tex/LaTex] how to get a hyphen in \mathrm


A simple question I think, but if I write $\omega{\mathrm{anti-Stokes}}$, the hyphen looks an awful lot like a minus sign. If I naively try $\omega{\mathrm{anti\hyp{}Stokes}}$ (I think \hyp{} requires \usepackage{hyphenat}) I get the same result – I'm not actually surprised, presumably it sets the same character.

A full MWE:



The minus sign looks like a rather thin en-dash instead of a hyphen.

Best Answer

This is to summarise the answers in the comments, and avoid leaving the question unanswered.

As discussed in more detail in the answers to Difference between various methods for producing text in math mode, there are several ways to produce upright letters in maths mode. Heiko Oberdiek's answer is particularly worth a read for the curious or confused.

Relevant here is that \mathrm is meant for setting upright characters in maths mode, and therefore uses the maths roman font, spacing and encoding. On the other hand \textrm uses the text roman font and the font parameters of the current text mode font, i.e. - will be encoded as a hyphen rather than a minus sign when using \textrm. Because \textrm inherits its parameters from the surrounding text, it doesn't guarantee an upright shape: for example in a theorem environment it will inherit italic shape. \textnormal uses \normalfont, only the size then changes

\textrm and \textnormal, in the absence of the amsmath package do not scale in subscripts, so amsmath must be loaded in cases like this, either directly or by another package such as mathtools which fixes some bugs in amsmath.