[Tex/LaTex] How to get custom-colored equation numbers as simply as possible

colorequationsnumbering

In a continuation of efforts to create a complete SAE technical paper class file, I need a little help finding the easiest way to create colored equation numbers. In my class file, I already define caption colors via the following:

\Requirepackage{color}
\definecolor{SAEblue}{rgb}{0, .62, .91}
\renewcommand\captionfont{\color{SAEblue}\small}

Similarly, in my mind, there must be a simple command I could alter, like:

\renewcommand\eqnumfont{color{SAEblue}}

However, I haven't found it on the forum. There are some more complicated examples, and also examples that define a \colorlabel property within equation or align environments, but I would like to define something within my class files that globally makes all equation labels my custom color. I'm not sure what package sets the color of equation numbers (by default).

Best Answer

Well, you can change \@eqnnum but whether this is what you want is impossible to say without more details about your class code and your desired results.

\documentclass{article}
\usepackage{xcolor,etoolbox}
\makeatletter
\patchcmd{\@eqnnum}{\normalcolor}{\color{magenta}}{\typeout{eqnnum patch: OK!}}{\typeout{eqnnum patch: Oh, dear!}}
\begin{document}
\begin{equation}
  1 + 2 = 3\label{eq:siml}
\end{equation}
\end{document}

magenta equation numbering