[Tex/LaTex] LaTeX command for equal (=)

macrossymbols

Is there a LaTeX command for the equal (=) sign? I'd like to overwrite the command so that all equal signs in my document are colored green. But it seems I cannot do it with just the symbol =, which is not a command.

Best Answer

Every character can be turned into a command in math mode, but some special tricks are needed.

\documentclass{article}
\usepackage{xcolor}

\begingroup\lccode`~=`=
\lowercase{\endgroup\def~}{\mathrel{\textcolor{green}{\standardequals}}}

\edef\standardequals{\mathchar\the\mathcode`=\relax}

\AtBeginDocument{\mathcode`=\string"8000 }

\begin{document}
$a=b$
\end{document}

enter image description here