# Getting cleveref to mark all of “Lemma 1” as a hyperlink, not just “1”

I recently discovered the very nice cleveref package, and really like. Works much better than autoref (from hyperref) for me. There is only one thing I don't like: If, for example, the \cref command inserts the text "Lemma 1", then only "1" is a clickable hyperlink. When using \autoref, the whole text is a hyperlink, which I really prefer (it's easier to hit the link).

Is there any way to get cleveref to work like this, too? Preferably one where I do not need to manually redefine the formatting for every reference type individually (i.e. for lemma, theorem, proposition, section, subsection, ...).

-
Welcome to TeX.SE. As you can see, another site member took the liberty to format your post a little. See this link for more details on available formatting. –  yo' May 3 '12 at 16:55

Pass the nameinlink option to the cleveref package

\usepackage[nameinlink]{cleveref}


A MWE follows, just for demonstration- see Section 6.2 of the documentation for details

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\section{Here is a section}\label{sec:mysection}
$$f(x)=x^2+\sin(x)$$

\cref{sec:mysection}
\end{document}

-
Aha! Seems the version of cleveref (version from 22/03/2011 as shipped with TeXLive 2011) is too old -- it doesn't support this option. Which is some relief, as I swear I searched the manual back and forth (I hate to ask questions and then find out they are answered in the manual). Time to upgrade the package, I guess. Thank you very much! –  Max May 3 '12 at 17:00
@Fingolfin not sure I understand- this works fine for me. Perhaps an update is in order? (I'm on TeXlive 2011), and my version of cleveref is dated 2012/03/07 –  cmhughes May 3 '12 at 17:02
@Fingolfilm -- If you still have the 22/03/2011 version of cleveref (instead of the current version, 0.18.5, dated 07/03/2012), your system may not be set up in a way that runs tlmgr (TeX Live Manager) from time to time to obtain the latest versions of various LaTeX packages. The nameinlink option of the cleveref package was added last fall. Do consult your sys admin (maybe you?) and ask him/her to run tlmgr update --self --all. (Superuser privileges are required to run this command.) –  Mico May 3 '12 at 17:21
@Mico great tip :) Note that one can change the permissions of /usr/local/texlive to be a normal user, in which case tlmgr does not need to be run as an admin. I'm not necessarily recommending it, just an FYI –  cmhughes May 3 '12 at 17:25
@Fingolfin -- I can understand your reluctance to run tlmgr entirely automatically. However, by not running tlmgr on a regular basis, you do incur the extra burden of having to be diligent about keeping an eye out for what's going on in the TeX world in terms of packages and updates -- including occasional significant improvements, as recently was the case with the cleveref package. Note that you can run tlmgr update --list --all to find out which packages would be updated (but without actually doing anything), and tlmgr update <pkg> to selectively update only one package at a time. –  Mico May 3 '12 at 18:01