Sometimes the symbol := is used to denote a definition. For example, X:=Y+Z means that X is defined to be Y+Z.
When using LaTeX, can I just use $:=$, or do I need to do something special?
Sometimes the symbol := is used to denote a definition. For example, X:=Y+Z means that X is defined to be Y+Z.
When using LaTeX, can I just use $:=$, or do I need to do something special?
Many do, but then the colon isn't correctly centered. Better to use the package mathtools and \coloneq. See the mathtools documentation for more information.
Note: In Summer 2022, this macro was changed to \coloneq (the older \coloneqq is still supported as legacy duplicate name).
Unfortunately, with $:=$, the colon is not centred on the math axis. A solution comes from the mathtools package, which defines \vcentcolon and \coloneqq commands; these lead to two different results, as regards the horizontal spacing between the colon and the equality sign. Compare:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\begin{document}
Let $ a: = b $
Let $ a \vcentcolon = b $
Let $ a \coloneqq b $
\end{document}

The \coloneq(one q!) symbol exists in mathabx, Mnsymbol and fdsymbol (at least). It's named \coloneqqin kpfonts and mdsymbol.
\coloneq (one q) in mathtools too. With note "As is listed in the manual for newtxmath/newpxmath" in the mathtools docs
– postylem
Mar 09 '24 at 16:31
It is not necessary to do anything, LaTeX does it for you.
\documentclass{article}
\begin{document}
Here
\[X:=Y+Z
\]
\end{document}
. does). This is of course wrong since the = is vertically centred and this assymetry is seriously ugly.
– yo'
Aug 01 '14 at 20:49
\newcommand{\defeq}{\overset{\mathrm{def}}{=\joinrel=}}, so$x\defeq 2$should do what you want. – Algeboy Feb 25 '22 at 05:40