# anchorcolor in hyperref not working?

I am trying to use the hyperref package to color internal links coming from \label as green, while those coming from anchored text via \hypertarget as red. However, in both cases, the relevant text appears green? I am using revtex4-1, but I don't think that this is the problem ...

\documentclass[a4paper]{revtex4-1}
\usepackage[pdftex]{xcolor}
anchorcolor=red]{hyperref}

\begin{document}

$$\text{this is an equation} \label{theeq}$$

This is the equation \ref{theeq} and it is green as expected.\\

\end{document}

• Maybe help this: tex.stackexchange.com/a/61016/31034 – user31034 Mar 8 '19 at 19:09
• It doesn't look as if the anchor color is used for pdflatex/luatex. I found it only in some of the more exotic drivers like textures. – Ulrike Fischer Mar 8 '19 at 19:29

Well, I suppose you report this bug to the maintainer of hyperref.

Until it is corrected you can use the following workaround:

\newcommand{\myhypertarget}[3][red]{\hypertarget{#2}{\textcolor{#1}{#3}}}%


Command \myhypertarget sets the colour red manually to the target text.

With the following MWE

\documentclass[a4paper]{revtex4-2}
\usepackage{xcolor}
\usepackage[%
anchorcolor=red
]{hyperref}

\newcommand{\myhypertarget}[3][red]{\hypertarget{#2}{\textcolor{#1}{#3}}}%

\begin{document}

$$\text{this is an equation} \label{theeq}$$

This is the equation \ref{theeq} and it is green as expected.\\

And this is with \texttt{\\myhypertarget}:

Please see that I deleted the driver pdftex for xcolor and hyperref. Also I used class revtex4-2, the current version of revtex.