我正在嘗試使用該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}
你得到結果:
請參閱我刪除了pdftex
和xcolor
的驅動程式hyperref
。我還使用了 class revtex4-2
,revtex 的目前版本。