How do I put unformatted text in an equation?

Sometimes, you want text to appear in an equation that doesn't have to be formatted mathematically, i.e., you don't want it to be in italic, etc. You can add text in an equation with the \textrm command. Note that this command is sensitive for white space characters.

The following example puts an "if" in normal formatted text within an equation

\begin{equation}
f(x)=0\textrm{ if }x>0
\end{equation}

Note that the spaces surrounding the "if" are included in the argument of the \textrm command! If you don't put the spaces in the \textrm command, all of the math before and after the command will stick to it and you'll get something like f(x)ifx>0 instead of f(x) if x>0.


comments powered by Disqus