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
のドライバーを削除したことを確認してください。また、 revtex の現在のバージョンであるクラス を使用しました。xcolor
hyperref
revtex4-2