Is there a way to reference things with \ref using a different color than with what \hypersetup
assigns it? That is, I would like to reference a theorem with blue text in general, but at some point I'd like to reference it with red text. I've tried using \textcolor
but that doesn't seem to override it.
1 Answer
You can switch colours mid-document using \hypersetup
:
\documentclass{article}
\usepackage{hyperref,xcolor}
\hypersetup{
colorlinks % Defaults to red
}
\begin{document}
\section{A section}\label{sec:section}
See Section~\ref{sec:section}.
\hypersetup{linkcolor=green}
See Section~\ref{sec:section}.
\hypersetup{linkcolor=red}
See Section~\ref{sec:section}.
\end{document}