What is the purpose of $:$?

We know that in math mode one should write in natural language and not being so strict with math notation.

For example: $f:A\to B$ is not "correct", the correct way would be $f\colon A\to B$ (and variants).

I do not remember any math book that uses the colon as part of a sentence in math mode.

The only 2 uses I can give to $:$ are when learning about divisions ($2:4=1:2$) and scales ($1:2$).

Does (La)TeX give a meaning of : in math mode?

  • 2
    The colon is not used for division in USA/British tradition. In scale ratios, I'd prefer spacing the colon as a relation rather than an operation.
    – egreg
    May 16, 2019 at 7:39

2 Answers 2


The : is a relational symbol in TeX. In the TeXbook it is used in conjunction with =.

Plain \TeX\ treats the four characters |=|, |<|, |>|, and |:|\ as
``^{relations}'' because they express a relationship between two
quantities. For example, `${x<y}$' means that $x$~is less than~$y$.
Such relationships have a rather different meaning from binary
operations like $+$, and the symbols are typeset somewhat differently:
|$x\le y\ne z$|&x\le y\ne z\cr
|$x\sim y\simeq z$|&x\sim y\simeq z\cr
|$x\equiv y\not\equiv z$|&x\equiv y\not\equiv z\cr
|$x\subset y\subseteq z$|&x\subset y\subseteq z\cr

In the comments, egreg pointed out another example in the TeXbook, where : is used to separate the condition from the set variable.

|$\{\,x\mid x>5\,\}$|&\{\,x\mid x>5\,\}\cr
(Some authors prefer to use a ^{colon} instead of `$\mid$', as in the second
example here.)

The colon has the exact same meaning in Plain TeX and LaTeX, as can be verified using this simple document:

\csname @@end\endcsname

The output is

$ pdftex test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdftex)
 restricted \write18 enabled.
entering extended mode
> 12346.
l.1 \showthe\mathcode`:

No pages of output.
Transcript written on test.log.
$ pdflatex test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2018-12-01>
> 12346.
l.1 \showthe\mathcode`:

No pages of output.
Transcript written on test.log.

Here the same table rendered in LaTeX:

enter image description here

|$x=y>z$|                 & x=y>z                 \\
|$x:=y$|                  & x:=y                  \\
|$x\le y\ne z$|           & x\le y\ne z           \\
|$x\sim y\simeq z$|       & x\sim y\simeq z       \\
|$x\equiv y\not\equiv z$| & x\equiv y\not\equiv z \\
|$x\subset y\subseteq z$| & x\subset y\subseteq z \\
  • 4
    I think := should be typeset with \coloneqq: tex.stackexchange.com/a/4217/156344. One should not use $a:=b$ as Knuth said.
    – user156344
    May 16, 2019 at 6:25
  • 3
    @Mico If you look in the Metafontbook, you will see “:=” clearly input as :=. Whether the mathtools macros \coloneqq should be used is a question of personal choice and taste (I would never use := in my math, of course). I agree that := is by no means “the” intended usage (see page 174 in the TeXbook for the main one). In proportions such as a:b=c:d I'd not treat the colon as a binary operation.
    – egreg
    May 16, 2019 at 7:36
  • 1
    @HenriMenke It is not “the” (in the sense of the unique) intended usage.
    – egreg
    May 16, 2019 at 7:53
  • 1
    @JouleV -- While \coloneqq exists now (and should now be used), it did not exist when TeX was created -- there simply wasn't enough memory to accommodate all possible symbols. May 16, 2019 at 13:33
  • 1
    @egreg For := I use always your \mathrel{\mathop:}= :-) from Comprensive list symbols.
    – Sebastiano
    May 16, 2019 at 15:08

Quite often, one sees : employed in place of a vertical bar (|) to denote conditioning on some event or condition. E.g., both $E(X : X>0)$ and $E(X\mid X>0)$ would express the "expectation of the random variable X conditional on this random variable taking on positive values".

By default, TeX treats both : and \mid -- but not | and \vert -- as "relational" operators and inserts an amount of whitespace around them that's also used for other relational operators such as <, =, and >.

For other, i.e., non-conditioning math uses of the colon symbol, one should employ \colon, \coloneq (or, depending on the package that's in use, \coloneqq, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.