In user700902's answer to this post, there is the following for-loop:
\@for\@tempa:=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\do{%
\expandafter\colorizemath\@tempa{green}}
If I want to put symbols like >, (, = along with a,b,c,..., how can I escape them?
Whole Document:
\documentclass[fontsize=11pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,hyperref,color,xcolor}
\newcommand*{\mathcolor}{}
\def\mathcolor#1#{\mathcoloraux{#1}}
\newcommand*{\mathcoloraux}[3]{%
\protect\leavevmode
\begingroup
\color#1{#2}#3%
\endgroup
}
\makeatletter
\def\colorizemath #1#2{%
\expandafter\mathchardef\csname orig:math:#1\endcsname\mathcode`#1
\mathcode`#1="8000
\toks@\expandafter{\csname orig:math:#1\endcsname}%
\begingroup
\lccode`~=`#1
\lowercase{%
\endgroup
\edef~{{\noexpand\color{#2}\the\toks@}}}%
}
\@for\@tempa:=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\do{%
\expandafter\colorizemath\@tempa{blue}}
\@for\@tempa:=A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z\do{%
\expandafter\colorizemath\@tempa{blue}}
\@for\@tempa:=0,1,2,3,4,5,6,7,8,9\do{%
\expandafter\colorizemath\@tempa{blue}}
\@for\@tempa:==\do{%
\expandafter\colorizemath\@tempa{brown}}
\def\m@th{\mathsurround\z@\color{black}}
\makeatother
\begin{document}
\title{Test File}
\author{ABC}
\maketitle
\section{Introduction}
The equation $1+1=2$ holds.
\end{document}

\@for\@tempa:==\do{% \expandafter\colorizemath\@tempa{green}}and it doesn't work. – Mika H. Mar 09 '13 at 20:59\makeatletterand\makeatother? Otherwise, explain what doesn’t work. Error message? Faulty output? Unexpected issues? (Unrelated to the question:=looses its\mathrelstatus with this.) – Qrrbrbirlbel Mar 09 '13 at 21:29! Bad mathchar (32768). <to be read again> \relax l.26 \begin{document}And yes, I'm between\makeatletterand\makeatother– Mika H. Mar 09 '13 at 21:34=is optional except when it isn't for example\let\a bis the same as\let\a=bbut if you wantbto be=you have to have\let\a==as teh first=is taken as part of the assignment. – David Carlisle Mar 09 '13 at 21:44hyperreftrying to save the mathcode of=. Probably one for Heiko Oberdiek! (You can't\mathchardefsomething that's set to math active, which is where the issue is.) – Joseph Wright Mar 09 '13 at 22:14=will be wrong. If the line\mathcode `#1="8000is turned into\AtBeginDocument{\mathcode `#1="8000 }the error disappears. – egreg Mar 09 '13 at 22:18amsmaththat is trying to save the math code, nothyperref! – Joseph Wright Mar 09 '13 at 22:20