How to typeset $:=$ correctly?

See the mathtools package, which offers the macro \coloneqq for this purpose.

\documentclass{standalone}
\usepackage{mathtools}
\begin{document}
\( b := 10 \) \emph{versus} \( b \coloneqq 10 \).
\end{document}

yields

Preview of the above document

Click image or right here to see it at full size (1600×133).

Note that the colon is slightly too low on the left, but vertically centered on the right.


This answer is an attempt to make Matthew happy, who doesn't like that the dots in the colon are so far apart. (@Matthew: I do understand that you don't like it.)

\makeatletter
\newcommand*{\defeq}{\mathrel{\rlap{%
                     \raisebox{0.3ex}{$\m@th\cdot$}}%
                     \raisebox{-0.3ex}{$\m@th\cdot$}}%
                     =}
\makeatother

EDIT:

To make Matthew even happier, I provide yet another answer that uses a different approach (motivated by the definition of \vdots) where the dots are smaller:

\newcommand*{\defeq}{\mathrel{\vcenter{\baselineskip0.5ex \lineskiplimit0pt
                     \hbox{\scriptsize.}\hbox{\scriptsize.}}}%
                     =}


I prefer Donald Arseneau's hack that can be found on the TeX FAQ (sorry, this links to a page in German):

\mathchardef\ordinarycolon\mathcode`\:
\mathcode`\:=\string"8000
\begingroup \catcode`\:=\active
  \gdef:{\mathrel{\mathop\ordinarycolon}}
\endgroup

Just put this code into your preamble. Then you can use := as usual, and you'll get horizontal symmetry. Much easier to use than \coloneqq, in my opinion.