So, using hyperref
I know how to change the color of "1" to blue when I say "using Theorem 1". But I want the entire "Theorem 1" to be blue. Similarly when I recall a lemma
/theorem
/proposition
/definition
I want it to be colored in blue including the number that appears after this.
1 Answer
Let's assume the theorem in question has been defined with a package such as amsthm
or ntheorem
and that it's been given the "label" thm:abc
.
Two suggestions:
Since you're loading the
hyperref
package, you could use the command\autoref{thm:abc}
to cross-reference the theorem.In addition to loading the
hyperref
package, you could load thecleveref
package with the optionnameinlink
. With this setup,\cref{thm:abc}
will also generate a cross-reference call-out in which both the name and the number of the theorem are colored.
For more information on cross-referencing possibilities and packages, see the posting Cross-reference packages: which to use, which conflict?
Here's an MWE (minimum working example) that uses some of the cross-referencing capabilities of the cleveref
package. To change the color used in the cross-references from red
(the default) to blue
, add the optio linkcolor=blue
when loading the hyperref
package.
\documentclass{article}
\usepackage{ntheorem}
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink,capitalize]{cleveref}
% set up a few theorem-like environments
\newtheorem{thm}{Theorem}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{defn}[thm]{Definition}
\begin{document}
% define
\begin{thm}\label{thm:abc} abc \end{thm}
\begin{lem}\label{lem:def} def \end{lem}
\begin{prop}\label{prop:ghi} ghi \end{prop}
\begin{defn}\label{defn:jkl} jkl \end{defn}
\noindent
\cref{thm:abc}, \cref{lem:def}, \cref{prop:ghi}, \cref{defn:jkl}.
\end{document}
\newcommand{\refth}[1]{{\color{blue}Theorem \ref{#1}}}
would be sufficient?