[Tex/LaTex] What’s the usual, standard way to write text in math mode

amsmatharraysequationsmath-modetext-mode

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.

Best Answer

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.

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

default textmode
\sffamily\itshape
current textmode
\(\text{text}\)
\(\textup{textup}\)
\(\textnormal{textnormal}\)
\(\textrm{textrm}\)
\(\mathrm{m ath rm-\sqrt{f}}\)

\end{document}

MWE