Anchorcolor no hiperref não funciona?

Anchorcolor no hiperref não funciona?

Estou tentando usar o hyperrefpacote para colorir links internos provenientes \labelde verde, enquanto aqueles provenientes de texto ancorado \hypertargetsão vermelhos. Porém, em ambos os casos, o texto relevante aparece em verde? Estou usando revtex4-1, mas não acho que esse seja o problema...

\documentclass[a4paper]{revtex4-1}
\usepackage[pdftex]{xcolor}
\usepackage[pdftex,breaklinks,colorlinks,
linkcolor=green,
anchorcolor=red]{hyperref}

\begin{document}

\begin{equation}
   \text{this is an equation} \label{theeq}
\end{equation}

This is the equation \ref{theeq} and it is green as expected.\\
\hypertarget{thelink}{This should be anchored}
\hyperlink{thelink}{ But its color is not red?}

\end{document}

Responder1

Bem, suponho que você relate esse bug ao mantenedor do hyperref.

Até que seja corrigido, você pode usar a seguinte solução alternativa:

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

O comando \myhypertargetdefine a cor redmanualmente para o texto de destino.

Com o seguinte MWE

\documentclass[a4paper]{revtex4-2}
\usepackage{xcolor}
\usepackage[%
  breaklinks,
  colorlinks,
  linkcolor=green,
  anchorcolor=red
]{hyperref}

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


\begin{document}

\begin{equation}
   \text{this is an equation} \label{theeq}
\end{equation}

This is the equation \ref{theeq} and it is green as expected.\\
\hypertarget{thelink}{This should be anchored}

And this is with \texttt{\\myhypertarget}: 
\myhypertarget{thelink1}{This should be anchored}
Text between target and link. Text between target and link. 
Text between target and link. Text between target and link. 
\hyperlink{thelink}{ But its color is not red?}

\hyperlink{thelink1}{ But its color is not red?}

\end{document}

você obtém o resultado:

pdf resultante

Por favor, veja que eu apaguei o driver pdftexpara xcolore hyperref. Também usei class revtex4-2, a versão atual do revtex.

informação relacionada