I usually use the colon symbol :
to denote maps. For set syntax there is the braket
package. So as the spacing of :
is not appropriate, I want it to behave like \colon
. I tried
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{braket}
\usepackage{dsfont}
\usepackage{mathtools}
\mathtoolsset{centercolon}
\def\textcolon{:} \catcode`\:=\active \def:{\relax\ifmmode\colon\else\textcolon\fi}
\begin{document}
Here is an example:
\begin{gather*}
f: x \mapsto x^2\\
g\colon \mathds R_+ \ni x \mapsto x^x \in \mathds R\\
A := \Set{ x \in \mathds R_+ | g(x) < x }
\end{gather*}
\end{document}
But that throws the error
! TeX capacity exceeded, sorry [grouping levels=255].
Without the active definition, it looks like
Notice that I use :=
for definitions. That should still be possible. The problem there is that \colon=
looks terrible:
As I agree with egreg, that using all the active math chars is not a good idea. I'm going with David's approach and use:
\AtBeginDocument{\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}}
\def\colon{\mathrel{:}}
\usepackage{mathtools}
\usepackage{newunicodechar}
\def\textcoloneq{≔} \newunicodechar{≔}{\ifmmode \mathrel{{\vcentcolon}{=}} \else \textcoloneq \fi}
\def\texteqcolon{≕} \newunicodechar{≕}{\ifmmode \mathrel{{=}{\vcentcolon}} \else \texteqcolon \fi}
I use \AtBeginDocument
so that I can use it together with fontspec
.
:=
for definitions as it does not vertically center the colon (notice that the dots of colon and the bars of the equal are not symmetric) Use\coloneqq
frommathtools
package orcolonequals
from thecolonequals
package. – Aditya Jul 23 '12 at 19:47\mathtoolsset{centercolon}
is for! – bodo Jul 23 '12 at 19:52