TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 17 down vote accepted

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

share|improve this answer
4  
Since the code is not too long, could you please explain how it works too, egreg? Thanks! – Mika H. Mar 9 '13 at 19:13
    
I'm asking also because I'd like to do other characters, like > < ) ( etc. – Mika H. Mar 9 '13 at 19:33
1  
@MikaH. It works similar to the accepted answer of LaTeX color setting for math mode. – Qrrbrbirlbel Mar 9 '13 at 19:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.