LatexNotes

Spacing in math mode in LaTeX

LaTeX ignores the spaces you type in maths mode and sizes gaps itself, so to add extra space you use explicit spacing commands, \, (thin), \; (thick), \quad and \qquad (wide), and \! to pull two symbols closer together.

LaTeX command

\quad

Not the symbol you meant? Draw it to find the command →

Inside a maths block, hitting the space bar does nothing, LaTeX's typesetting engine decides spacing around operators and relations automatically based on the symbols either side. When you want extra room, for example before a dx in an integral, you insert one of the spacing commands directly.

The commands form a small ladder from smallest to largest: \, (thin space, about 3/18 em), \; (thick, about 5/18 em), \quad (a full em, roughly the width of the current font's M), and \qquad (two ems). \! is the only negative one, it removes a thin space, handy for tightening symbols that look too loose next to each other.

The most common real use is \int f(x) \, dx, the thin space keeps the differential from crowding into the function. \quad or \qquad are the natural choice for separating a formula from trailing words or a second formula on the same line, rather than chaining several \, together.

Other forms

\,thin space
\;thick space
\qquaddouble quad
\!negative thin space

Examples

$\int f(x) \, dx$

a thin space before dx

$a \quad b \qquad c$

quad and double-quad gaps

$\{\, x \mid x > 0 \,\}$

thin spaces framing set-builder notation

$\int\!\!\int_D f(x,y)\,dA$

negative thin spaces tightening two integral signs

$5\,\text{km/h}$

a thin space before a unit

Tips and common mistakes

Working from handwritten notes?

LatexNotes turns a photo or PDF of handwritten mathematics into clean, compilable LaTeX - graphs and all. Free to try, no sign-up.

Convert your maths to LaTeX →

FAQ

Why don't my spaces show up in an equation?

Maths mode ignores literal spaces and spaces its own symbols automatically; use \,, \;, \quad or \qquad to insert a deliberate gap.

What's the difference between \quad and \qquad?

\qquad is exactly twice the width of \quad, both roughly the width of the current font's capital M; use \quad for a normal gap and \qquad when you want it doubled.

How much space does \, add?

\, is a thin space, about 3/18 of an em, the smallest of the standard spacing commands, typically used before a differential like dx.

How do I remove space instead of adding it?

Use \!, a negative thin space, it pulls the following symbol slightly closer, commonly seen tightening two consecutive integral signs or a cramped nested expression.

See also