Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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, ...).

share|improve this question
    
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. –  tohecz May 3 '12 at 16:55

1 Answer 1

up vote 16 down vote accepted

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}
\usepackage[nameinlink]{cleveref}

\begin{document}

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

\cref{sec:mysection}
\end{document}
share|improve this answer
1  
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
1  
@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
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.