Tx · LaTeX & TikZ

How Should You Space Quantifiers in LaTeX?

Published By the 9to5Science editorial team

At a glance

  1. 1. Keep the quantifier close

    Write the quantifier next to its variable, as in \forall x.

  2. 2. Separate clauses

    Use a thin space after a quantified variable when another quantifier follows.

  3. 3. Let relations space themselves

    Commands such as \in and \implies provide their own mathematical spacing.

  4. 4. Use wider gaps sparingly

    Use \quad for a substantial break, such as between a formula and explanatory text.

Quantifiers often look cramped when you type them in LaTeX because spaces in the source code are ignored in math mode. The usual fix is not to add a space between a quantifier and its variable, but to add a deliberate small space between quantified clauses.

The usual pattern

Write the quantifier directly next to the variable it governs, then use \, (a thin math space) before the next clause:

\forall x\in X\,\exists y\in Y\, R(x,y)

This renders the quantifier-variable pairs as units, with a slight gap between the clauses. The relation symbol \in supplies its own spacing around itself, so you do not need to insert spaces around it manually.

A common alternative is to use parentheses to make the scope especially clear:

\forall x\in X\,\bigl(\exists y\in Y\; R(x,y)\bigr)

Here \; adds a wider space before the predicate inside the parentheses. That extra space is optional; use spacing to support readability, not to compensate for every ignored source-code space.

Why source spaces do not work

In ordinary text, a typed space creates a visible word space. In math mode, LaTeX generally ignores ordinary spaces in the input. Thus these expressions have the same spacing:

\forall x \exists y P(x,y)
\forall x\exists y P(x,y)

The quantifier and variable are mathematical symbols, and TeX does not insert a word space between them. Adding \ can force a space, but it is usually not the right choice for standard quantified notation: a full text-like gap between \forall and x can make them look less like one quantifier-variable unit.

A complete example

This minimal document uses the amsmath package and displays two common styles. The first uses nested quantifiers; the second uses a quantifier followed by a predicate.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
  \forall x\in X\,\exists y\in Y\, R(x,y)
\]

\[
  \forall x\in X,\quad P(x)
\]

\end{document}

In the first display, \, separates the two quantified clauses and the predicate. In the second, the comma separates the domain condition from the following expression, while \quad deliberately makes a larger gap before P(x). The wide gap is a stylistic choice; if the expression is intended as one continuous formula, a comma and normal mathematical spacing may be enough.

Choosing a spacing command

LaTeX provides several explicit math spaces. Use the smallest one that makes the structure clear:

CommandRelative sizeTypical use
\,thinSeparating adjacent parts of a formula
\:mediumA more noticeable mathematical gap
\;thickA clear separation within a formula
\quadwideSeparating a formula from explanatory text or another condition

These commands work in math mode. For standard quantified formulas, \, is usually a good choice between one quantified clause and the next. You do not need to use the same spacing everywhere: punctuation and relation symbols already have spacing rules built into their mathematical classes.

If you are writing words rather than symbolic notation, use text inside the formula. For example, \text{for every } x (available with amsmath) is appropriate when the words are part of a sentence. It is different from writing the formal symbol \forall.

Common mistakes

  • Adding ordinary source spaces: \forall x \exists y does not gain a word-like gap from the spaces typed in the source. Use \, where a deliberate mathematical gap is wanted.
  • Putting a large gap between the quantifier and its variable: In formal notation, \forall x is normally kept together. A thin space is more useful after the variable when another clause follows.
  • Adding spaces around every relation: \in, =, and similar relation symbols already receive appropriate spacing. Extra commands can make the formula look uneven.
  • Using \quad between every symbol: A quad is much wider than a thin space and can make a formula appear broken into separate pieces. Reserve it for a genuine visual separation.
  • Ignoring scope: When a formula could be read in more than one way, use parentheses to show which statement a quantifier governs. Spacing alone does not determine logical scope.

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.