Text Formattingcleveref | Label Formatting for Hyperlinks

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pandammonium
Posts: 55
Joined: Thu Oct 30, 2008 4:12 pm

cleveref | Label Formatting for Hyperlinks

Post by pandammonium »

Hi,

I am using the cleveref package, but I don't understand the documentation for the \crefdefaultlabelformat command. The command sets how much of the reference, e.g. "fig. 2" to be put into a hyperlink. The default behaviour is to include only the number in the link, as if you were using \ref. I'd like the behaviour to mimic \autoref in the hyperref package. I have tried the following, with the stated results:

Code: Select all

\crefdefaultlabelformat{#2#1#3} % the same as the default; obviously made no difference;
\crefdefaultlabelformat{#2\thefigure #1#3} % the doc. gives \theequation as an example, so I tried this, but still no difference;
\crefdefaultlabelformat{#2\thelabel #1#3} % thought I'd go generic, but still no difference;
\crefdefaultlabelformat{#2\label #1#3} % still no difference;
\crefdefaultlabelformat{#2\thefigure #3} % thought it might be that I didn't need the '#1'.  No difference;
I have searched the internet for help on this, but I couldn't find any examples of the command in use. So, I know what I should <em>not</em> be doing; what should I be doing?

As ever, your time is appreciated,

pandammonium

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

lauraf
Posts: 29
Joined: Tue Jan 13, 2009 12:44 pm

Re: cleveref | Label Formatting for Hyperlinks

Post by lauraf »

I have also been trying to understand how to do this from the cleveref manual, but to no avail...

So I am posting a reply to liven up the topic, in case someone has figured this out in the meantime!

Many many thanks!
lauraf
Sculthorpen
Posts: 1
Joined: Wed Aug 04, 2010 1:19 pm

Re: cleveref | Label Formatting for Hyperlinks

Post by Sculthorpen »

I've got the same problem. As far as I can tell there is no command to do this for everything, but as a workaround each type can be done individually. E.g.

\Crefformat{chapter}{#2{}Chapter #1{}#3}
\Crefformat{section}{#2{}Section #1{}#3}
\Crefformat{appendix}{#2{}Appendix #1{}#3}
\Crefformat{figure}{#2{}Figure #1{}#3}
\Crefformat{table}{#2{}Table #1{}#3}

It feels like there should be a "\crefdefaultformat" command to do this automatically.
simonr
Posts: 1
Joined: Wed Jul 20, 2011 5:00 pm

Re: cleveref | Label Formatting for Hyperlinks

Post by simonr »

I had the same problem - I did resort to Sculthorpen's suggestions for a while. I've just found the latest version of cleveref (http://www.dr-qubit.org/latex.php#cleveref), though, which has added the option 'nameinlink' to do this for all references automatically.
Post Reply