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\!bNegative thin space, −3/18 em.
a\,bThin space, 3/18 em (about 1.7 pt).
a\:bMedium space, 4/18 em (also
\>).a\;bThick space, 5/18 em.
a\ bA normal interword space.
a\quad b1 em, the width of an M.
a\qquad b2 em.
a\hspace{1cm}bAny 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.
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.
Thin space before dx
LaTeX\int_0^1 f(x)\,dxSpace before a condition
LaTeXf(x) = x^2, \quad x \in \mathbb{R}Words inside a formula
LaTeXx > 0 \quad \text{for all } t \ge 1Thousands separator
LaTeX1\,000\,000Number and unit
LaTeX9.81\,\mathrm{m/s^2}Tightening a double integral
LaTeX\int\!\!\int_D f\,dA
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 off(x) = x^2, x > 0Writef(x) = x^2, \quad x > 0Without the thin space the dx sticks to the integrand.
Instead of\int f(x) dxWrite\int f(x)\,dxSome 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
\quador\thinspand 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.
- Handwritten math to LaTeXPhotograph notes or a whiteboard and get LaTeX for every line.1 credit per image
- PDF to LaTeXTurn a paper or textbook PDF into a .tex project with every equation.10 credits per page
- Image to WordA screenshot or photo of a page becomes Word with editable equations.10 credits per image
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,\quadfor a lot; normal spaces are ignored in math mode. - What is the difference between \quad and \qquad?
\quadis 1 em wide,\qquad2 em.- How do I remove space?
\!takes away a thin space.
Related LaTeX reference
- Math Mode in LaTeXInline math with $…$ or \(…\), displayed math with \[…\], numbered equation environments, references and \text inside formulas.
- How to Write a Multiline Equation in LaTeXalign and align* for aligned lines, aligned inside $$ … $$, split, gather and multline for long formulas and systems of equations.
- Integral in LaTeX\int with lower and upper limits, \iint and \iiint, contour integrals, evaluation bars and the thin space before dx.
- Brackets in LaTeXRound, square, curly and angle brackets, and how to size them with \left … \right, \middle and \big … \Bigg.
- How to Write a Norm in LaTeX‖x‖ with \lVert … \rVert or \|, auto-sizing with \left/\right, subscripted norms and a reusable \norm macro.
- Binomial Coefficients (Choose) in LaTeX\binom{n}{k} for n choose k, the older {n \choose k}, \dbinom and \tbinom sizes, and multinomial and combination notation.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
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