# Using \colon or : in formulas?

I noticed that in many documents you encounter $f: X \to Y$ instead of $f \colon X \to Y$. Another example are quantified expressions: $\forall x: P (x)$ versus $\forall x \colon P(x)$. I find the \colon visually more pleasing, however I sometimes think I seem to be the only one, given the overwhelming amount of documents that seem to use :. Is there a rule of thumb to decide where you should use either \colon or :?

-
In the AMS (American Mathematical Society) Short Math Guide for LaTeX you'll find both a recommendation (page 8) to use f\colon a \to b (rather than f : a \to b) and a general discussion of relation symbols. –  Z Norwood Mar 2 '12 at 23:50

Both : and \colon typeset a colon, but \colon is a punctuation symbol, while : is considered as a relation symbol as regards to spacing.

The main use of : is in set descriptions

\{\, x : x \notin x \,\}


(somebody uses \mid for this, where a simple | would be wrong; thin spaces after \{ and before \} are recommended by Knuth, be consistent in using them or not).

Conversely, \colon should be used for mappings

f\colon A \to B


but unfortunately many writers don't make this distinction and use :, getting a wrong spacing.

The rule to follow is just the same: use \colon when it's a "punctuation colon", use : when it represents a relation between what's at its left and at its right. In something like "for all x:" I would consider the colon as punctuation, so \forall x\colon

-
And use : for ratios. e.g. $x:y:z = 3:4:5$. –  Leo Liu Dec 10 '11 at 11:25
@LeoLiu Alternatively, \mathbin{:} could be used. Which one is a matter of personal taste. Most important is consistency across the document. –  egreg Dec 10 '11 at 11:32
How does one distinguish between "punctuation" and "relation"? The notation f\colon A\to B does denote a relation between f and A\to B, namely the relation "has type". And I don't see in what sense the colon in \{\, x : x\notin x \,\} denotes a "relation" between x and x\notin x. –  Mike Shulman Apr 11 '12 at 10:29
@MikeShulman It's a matter of conventions; usually the colon for maps is considered as punctuation, the one in set descriptions as a relation symbol. Be coherent in your document. –  egreg Apr 11 '12 at 12:30
There's also a colon product, isn't there? I'd start typing the equation here as $\mathbf{AB}\mathbin{:}\mathbf{CD}..., since the colon appears to be a binary operator. – MSC May 5 '12 at 0:09 show 1 more comment If you're trying to typeset a variable-has-type colon in type theory, you want {:} or \mathord{:} (they display the same). For example, you'll get a nice looking STLC identity function with $\lambda x {:} A . x\$.

See this page for a more general discussion.

-
@egreg: thanks! I updated the answer per your comment. –  ntc2 Dec 29 '13 at 13:28