LatexNotes

Lesson 11 of 12

Text and spacing

Words inside maths, the spacing commands, and the two heights of dots. About eight minutes.

Lesson 1 showed that maths mode ignores your spaces and turns words into italic letters. This lesson is about the two fixes: \text for words, and the spacing commands for the few places LaTeX's own spacing needs help.

Words inside maths

\text{...} writes upright words, and inside it your spaces count again:

f(x)=0 for all xf(x) = 0 \text{ for all } x

Notice the spaces inside the braces, \text{ for all }: without them the words run into the maths on either side.

\textbf{...} and \textit{...} give bold and italic words in the same way.

The spacing commands

From smallest to largest:

CommandSpace
\!a little less (negative)
\,thin
\:medium
\;thick
\quadthe width of an M
\qquadtwice that

Try the difference:

a bcda \, b \quad c \qquad d

Where they help

LaTeX spaces almost everything correctly by itself. The usual exceptions:

  • Before the dx of an integral: \int f(x) \, dx.
  • Between a root or a number and what follows: \sqrt{2} \, x.
  • Between separate parts of one line: x = 1, \quad y = 2.
  • Before a condition: x^2 \geq 0 \quad \text{for all } x.
x=1,y=2x = 1, \quad y = 2

Dots

Three dots come in two heights:

  • \ldots sits low, between commas: 1,2,…,n1, 2, \ldots, n.
  • \cdots sits in the middle, between operators: a1+a2+⋯+ana_1 + a_2 + \cdots + a_n.

\vdots and \ddots are the vertical and diagonal dots from lesson 9.

1+2+⋯+n=n(n+1)21 + 2 + \cdots + n = \frac{n(n+1)}{2}

Practise

Here the spaces count, so type them where the formula shows them.

  1. f(x)=0 for all xf(x) = 0 \text{ for all } x

  2. x2≥0for x∈Rx^2 \geq 0 \quad \text{for } x \in \mathbb{R}

  3. ∫01x dx\int_0^1 x \, dx

  4. x=1,y=2x = 1, \quad y = 2

  5. 1,2,…,n1, 2, \ldots, n

  6. a1+a2+⋯+ana_1 + a_2 + \cdots + a_n

  7. 2 x\sqrt{2} \, x

In short

  • \text{...} writes words, and spaces inside it count.
  • \, \: \; \quad \qquad add space, and \! takes a little away.
  • \ldots between commas, \cdots between operators.

Next, in lesson 12: a full worked solution, from first line to last.

Would you rather write it by hand?

LatexNotes turns a photo or PDF of your handwritten maths into LaTeX like this. Free to try, no sign-up.

Convert your handwriting to LaTeX →