All guides

Text in equations in LaTeX

Updated:

In math mode every letter is a variable and is set in italics. Put words, descriptive subscripts and abbreviations inside \text from amsmath. For single upright symbols, like the d in a differential or the constant e, you can use \mathrm.

A phrase in an equation

v = \frac{s}{t} \quad \text{for uniform motion}
v=stfor uniform motionv = \frac{s}{t} \quad \text{for uniform motion}

\quad adds a space as wide as the letter M to separate the text from the formula. Inside \text spaces work normally; in math mode itself they are ignored.

Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free

Descriptive subscript

T_{\text{boil}} = 373\,\mathrm{K}
Tboil=373 KT_{\text{boil}} = 373\,\mathrm{K}

A word subscript goes through \text, and a unit through \mathrm with a thin space \, before it. Both should be upright, since neither is a variable.

A variable inside a sentence

P = \frac{W}{t} \quad \text{where } W \text{ is the work done}
P=Wtwhere W is the work doneP = \frac{W}{t} \quad \text{where } W \text{ is the work done}

A variable inside the sentence goes outside \text: close the braces, type W and open \text again, remembering the spaces at the edges.

Constants set upright

\mathrm{e}^{\mathrm{i}\pi} + 1 = 0
eiπ+1=0\mathrm{e}^{\mathrm{i}\pi} + 1 = 0

\mathrm is for single symbols that are not variables: the number e, the imaginary unit i or the differential d. Spaces inside \mathrm are ignored, so it is no good for words.

Your own function name

\operatorname{sgn}(x) = \frac{x}{|x|}
sgn⁡(x)=x∣x∣\operatorname{sgn}(x) = \frac{x}{|x|}

A function name LaTeX does not know, such as sgn or erf, goes through \operatorname from amsmath. It gets an upright font and the right spacing before the argument, just like \sin.

A sentence between equation lines

\begin{align}
  x &= 2 \\
  \intertext{and substituting into the second equation}
  y &= 4
\end{align}

\intertext from amsmath puts a sentence between the lines of an aligned block without breaking the alignment of the equals signs. The text starts at the left margin like a normal paragraph.

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free