hyperref 中的錨色不起作用?

hyperref 中的錨色不起作用?

我正在嘗試使用該hyperref包將來自的內部連結著色\label為綠色,而來自錨定文字的內部連結則著色\hypertarget為紅色。然而,在這兩種情況下,相關文字都顯示為綠色?我正在使用revtex4-1,但我不認為這是問題...

\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}

答案1

好吧,我想您將此錯誤報告給了hyperref.

在問題得到糾正之前,您可以使用以下解決方法:

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

命令手動\myhypertarget將顏色設定red為目標文字。

具有以下 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}

你得到結果:

產生的pdf文件

請參閱我刪除了pdftexxcolor的驅動程式hyperref。我還使用了 class revtex4-2,revtex 的目前版本。

相關內容