How to Add Space in LaTeX Equations

Spaces you type in math mode are ignored, so use commands: \, (thin), \: (medium), \; (thick), \quad (1 em) and \qquad (2 em). \! removes a thin space, and \hspace{1cm} adds any width.

Spacing commands (widths in a 10 pt font)

  • a\!b
    a b

    Negative thin space, −3/18 em.

  • a\,b
    a b

    Thin space, 3/18 em (about 1.7 pt).

  • a\:b
    a b

    Medium space, 4/18 em (also \>).

  • a\;b
    a b

    Thick space, 5/18 em.

  • a\ b
    a   b

    A normal interword space.

  • a\quad b
    a b

    1 em, the width of an M.

  • a\qquad b
    a b

    2 em.

  • a\hspace{1cm}b
    a b

    Any length: cm, pt, em, ex.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Spaces in equations examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

Why typed spaces disappear

In math mode LaTeX sets the spacing itself from the type of each symbol: a little around +, more around =, none between a letter and a parenthesis. That is why a b and ab look the same. You only add space by hand for a few cases: before dx, between a formula and a condition, and between number and unit.

Space for alignment and text

Inside \text{} spaces work as in normal text, so \text{for all } keeps its trailing space. \phantom{x} reserves the exact width of x without printing it, which helps line up columns. Vertical space between equation lines is added with \\[6pt].

Common mistakes

  • Extra spaces in math mode are ignored.

    Instead of
    f(x) = x^2,    x > 0
    Write
    f(x) = x^2, \quad x > 0
  • Without the thin space the dx sticks to the integrand.

    Instead of
    \int f(x) dx
    Write
    \int f(x)\,dx
  • Some renderers limit \hspace; the named spaces work everywhere.

    Instead of
    \hspace{1cm}  (in KaTeX inline math)
    Write
    \quad

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    All commands work in math mode without packages.

  • MathJax and KaTeX

    MathJax and KaTeX support \, \: \; \! \quad \qquad, \ and \hspace.

  • Microsoft Word

    In a Word equation type \quad or \thinsp and Space to insert spaces; normal spaces are also ignored there.

Have this math on paper, in a PDF or a photo?

Retyping formulas is slow. These converters read whole pages and handwriting and give you LaTeX or Word with every equation editable.

Single printed formulas are free: 3 a day without an account, 6 with a free account. New accounts get 30 credits to try handwriting, pages and documents; failed conversions return their credits. See plans and credit prices.

Spaces in equations in LaTeX: questions

How do I add a space in a LaTeX equation?
Use \, for a little, \quad for a lot; normal spaces are ignored in math mode.
What is the difference between \quad and \qquad?
\quad is 1 em wide, \qquad 2 em.
How do I remove space?
\! takes away a thin space.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX