¿El color de anclaje en Hyperref no funciona?

¿El color de anclaje en Hyperref no funciona?

Estoy tratando de usar el hyperrefpaquete para colorear los enlaces internos que provienen \labelde verde, mientras que los que provienen de texto anclado son \hypertargetde rojo. Sin embargo, en ambos casos, ¿el texto relevante aparece en verde? Estoy usando revtex4-1, pero no creo que ese sea el 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}

Respuesta1

Bueno, supongo que informarás de este error al responsable de hyperref.

Hasta que se corrija, puede utilizar la siguiente solución alternativa:

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

El comando \myhypertargetestablece el color redmanualmente según el texto de destino.

Con el siguiente 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}

obtienes el resultado:

pdf resultante

Tenga en cuenta que eliminé el controlador pdftexde xcolory hyperref. También usé class revtex4-2, la versión actual de revtex.

información relacionada