2

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
  • something like \newcommand{\refth}[1]{{\color{blue}Theorem \ref{#1}}} would be sufficient?
    – ebosi
    Commented Jun 16, 2016 at 12:59

1 Answer 1

2

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:

  1. Since you're loading the hyperref package, you could use the command \autoref{thm:abc} to cross-reference the theorem.

  2. In addition to loading the hyperref package, you could load the cleveref package with the option nameinlink. 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.

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .