Я пытаюсь использовать 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
. Также я использовал класс revtex4-2
, текущую версию revtex.