4

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).

1
  • We need a complete minimal example as we don't know what is formatting your equation numbers by default in your class.
    – cfr
    Feb 12, 2016 at 2:33

3 Answers 3

4

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

4
  • This is great. I just need to figure out what package is blocking me from being able to use this in my class file. It works as a MWE but not in my test document.
    – R.K.G.
    Feb 12, 2016 at 16:30
  • Ok, I determined this doesn't work because of the mhchem package I am using for making pretty looking chemical formulas in my document. Now to figure out why...
    – R.K.G.
    Feb 12, 2016 at 17:00
  • Ok I'm going to formulate this into a new question with a very simple MWE as I think that would be the appropriate way forward.
    – R.K.G.
    Feb 12, 2016 at 17:15
  • Continuing this issue in the following thread to find a solution that is compatible with amsmath. tex.stackexchange.com/questions/292583/…
    – R.K.G.
    Feb 12, 2016 at 19:55
8

You can use the \newtagform and \usetagformcommands, defined by mathtools, and have different styles for tags within the same document:

\documentclass{article}

\usepackage{mathtools}
\usepackage[x11names]{xcolor}
\newtagform{blue}{\color{RoyalBlue3}(}{)}
\newtagform{redandblue}[\textcolor{RoyalBlue3}]{\color{red}(}{)}
\begin{document}
\usetagform{blue}
\begin{equation}
\label{blueeq}
  a =b + d
\end{equation}
From \eqref{blueeq} we deduce: 
\usetagform{redandblue}
\begin{equation}
\label{RandB}
c = d \times e
\end{equation}
But \eqref{RandB} does not imply \usetagform{blue}\eqref{blueeq}.

\usetagform{default} 
\begin{equation}
  f =g + h
\end{equation}

\end{document} 

enter image description here

3

If you only want the equation number coloured then redefine \theequation:

enter image description here

Here's the code:

\documentclass{article}
\usepackage{color}
\definecolor{SAEblue}{rgb}{0, .62, .91}
\renewcommand\theequation{{\color{SAEblue}\arabic{equation}}}
\begin{document}
\begin{equation}
    1+1=2+\varepsilon
\end{equation}
\end{document}

If you want the brackets coloured as well then @cfr has the answer:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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