# Coloured equation number (without changing colour of reference using hyperref)

I am working on a file where I am using the package hyperref so that the references to equations are linked and coloured. Here is a MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}

\begin{document}

$$1=\beta\left[ \frac{ 1+\left( 1-\tau_{t+1}\right) r_{t} }{\Pi_{t+1}} \right]\label{Fisher}$$

Make reference to \eqref{Fisher}.

\end{document}


This gives me the reference at the end red, which is great. Now I want to have the equation number in blue (not the reference to the equation, but the equation number itself). I achieve that by adding

\renewcommand\theequation{{\color{blue}\arabic{equation}}}


to the preamble, before of after hyperref (the result seems to be the same). On first compile, great, I get the exact result I want: the equation number is blue, and the reference to the equation is in red:

but a second compile will turn both the equation number and the reference to the equation blue!

How can I avoid that, and have my equation number in blue not interfere with the equation reference colour from hyperref?

-

You can adapt this answer by Andrew Stacey

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\let\reftagform@=\tagform@
\def\tagform@#1{\maketag@@@{(\ignorespaces\textcolor{blue}{#1}\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{\reftagform@{\ref{#1}}}}
\makeatother
\usepackage{hyperref}
$$1=\beta\left[ \frac{ 1+\left( 1-\tau_{t+1}\right) r_{t} }{\Pi_{t+1}} \right]\label{Fisher}$$

Great, that works. I just wish I could do those things myself. Are the \let, \tagform@, etc commands part of LaTeX or are they TeX? Also, is the problem related to amsmath rather than hyperref as the link you provided seems to suggest? –  Vivi Apr 3 '12 at 1:01
@Vivi \let is a primitive TeX command: we save a copy of \tagform@ (an internal of amsmath) before redefining it. As I commented there, it's a weakness of amsmath that uses the same command for two different purposes. –  egreg Apr 3 '12 at 8:11