Skip to main content

The PreTeXt Guide

Subsection 4.9.5 Text in Mathematics

Once in a while, you need a little bit of “regular” text within an expression and you do not want it to look like a product of a bunch of one-letter variables. Use the \text{} macro for these. Only. Other ways of switching out of math-mode and into some sort of “regular” text will appear inferior, and can raise errors in certain conversions.
  • Do place surrounding spaces inside the \text{} macro.
  • Do not place any mathematics inside the \text{} macro.
  • Do not use the \mbox{} macro as a substitute.
  • Do not use font-changing commands (e.g. \rm) as a substitute.
For example,
<me>f(x) = \begin{cases} x^2 \amp \text{if } x\gt 0\\
           -7 \amp \text{otherwise} \end{cases}</me>
\begin{equation*} f(x) = \begin{cases}x^2\amp\text{if }x\gt 0\\-7\amp\text{otherwise}\end{cases}\text{.} \end{equation*}
This example amply illustrates the use of macros for XML exceptional characters (twice), appropriate use of the \text{} macro (twice), spaces in the \text{} macro (once), sentence-ending punctuation (see the source, the period is not inside the <me> element) and yes, we did think twice about the \\ (an exception to the rule).