This previous question asks about several options for escaping math mode to write text-like things. The accepted answer describes what each of those options do, and why. But which of those options produces output that looks like the usual, standard way to write non-mathy things in an equation (e.g. 'if', 'otherwise' in a piecewise-defined function)?

I'm not necessarily asking about spacing issues like in this previous thread since my examples are somewhat simple, but if it's relevant I'm interested in that too.

  • 3
    Have you tried \text{if $x<0$} and \text{otherwise}?
    – Mico
    Oct 2, 2017 at 14:20

2 Answers 2


Based on David's answer, but with the fonts set up in a way to reveal as much about the commands as possible.

  • \text just uses the text mode from "outside" with all the formatting.
  • \textup is similar, only upright.
  • \textnormal sets its content back to the normal document font without any other formatting.
  • \textrm keeps all the text formatting, it only resets the font family.
  • \mathrm behaves differently, I think of it as upright math mode, which is shown in my example text with the CM font, the minus sign, gobbled space and square root without the compiler complaining about switching into math mode—it already is.

There is no definitive answer in my mind. Depending on how much formatting you want to keep, choose your command among the \text... commands. Text mode is sans-serif italic in my example.

\usepackage{amsmath} % for \text
\usepackage{newtxtext} % Times-like font
\obeylines % automatic linebreaks

default textmode
current textmode
\(\mathrm{m ath rm-\sqrt{f}}\)



  • 1
    you say \mathrm is weird but I would say that in the majority of cases that you need a roman font on math mode, \math... is the natural command to use rather than \text... Oct 2, 2017 at 17:14
  • @David Carlisle: I understand \mathrm better now, so "weird" is not a good description, I agree. I do think that there is a difference in kerning between text mode and math mode \mathrm, in the same way as the math italic is kerned wider than the text italic, but in my tests I can only show it with CM italics, not upright \mathrm.
    – lblb
    Oct 2, 2017 at 17:49
  • in the default setup mathrm and texrm are the same font but that need not be the case, try fro example adding \usepackage{times} and then \text will use times roman and \mathrm will use cm. Actually the situation is similar with math italic, it isn't that tex adds different kerning in math italic, it is simply a different font which typically has wider sidebearings Oct 2, 2017 at 17:51
  • @DavidCarlisle: Your point is exactly what my MWE above shows as well with a Times-like font. The thing I'm not sure about is whether \mathrm applies wider math kerning, something I was only able to see with text vs math italics.
    – lblb
    Oct 2, 2017 at 17:53
  • 1
    as I say tex never "applies wider kerning" to math rm or math italic. The widths of the characters and any inter-character kerns are specified by the font not by tex. Oct 2, 2017 at 17:54

The usual and standard way to write text in math mode is using \hbox{ text }. Only this solution is format independent, so only this solution will work outside LaTeX (for example). You didn't specify the format of TeX you are using, so this is recommended solution for you.

  • 3
    what I admire most is the calm equanimity of your comment about format of TeX; it is hard to believe you are not tongue in cheek when you leave open the possibility the OP knows something else than LaTeX, but I have to assume you are not in joking mode.
    – user4686
    Oct 2, 2017 at 17:27
  • 3
    In wipet's response, take note that the word inside the {} has both a leading and a trailing space. Not inserting these spaces will butt the word right up against the math characters.
    – TommyK
    Oct 2, 2017 at 17:41
  • 3
    wipet you know all the problems with this, notably the failure to get smaller in subscripts. While posting a plain tex solution is Ok you really shouldn't misinform people, and provide a proper code that works in a reasonable range of cases. Oct 2, 2017 at 17:48
  • @DavidCarlisle I was surprised that all others posts here suppose only LaTeX and the "standard" way \hbox was not mentioned here. The word "standard" (from name of this thread) means format independence in first case, IMHO. Of course, there are some problems. They can be solved for example by petr.olsak.net/opmac-tricks-e.html#mathbox, when LaTeX is not used.
    – wipet
    Oct 2, 2017 at 18:43
  • 2
    so your answer (without the extension in these comments) is highly misleading, it only applies to that tiny fraction of users who write documents in plain tex, and for them it does not provide a general solution) Oct 2, 2017 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .