30

I’d like to use the cleveref package but I don’t like that it inserts most names as abbreviations; for instance, it will print “… fig. 2.1 …” instead of “… figure 2.1 …”.

Is there a way of changing that without manually changing all the crefnames? There doesn’t seem to be an appropriate option.

Furthermore, when used in conjunction with the hyperref package, only the number is actually linked. The text in front of it (“figure” in my example) isn’t. Can this also be changed (again, without redefining all the commands)?

4
  • 1
    Which are those names? Afaik there are just 2 abbreviations for figure and equation. So, 2 \crefname would be sufficient.
    – Stefan Kottwitz
    Commented Dec 2, 2010 at 18:45
  • @Stefan: whoops. How weird. I hadn’t actually paid attention to that. Fair enough, that’s a manageable scope. Commented Dec 2, 2010 at 19:15
  • 7
    You want the noabbrev package option. It's one of the first things in the manual!
    – Noldorin
    Commented Aug 25, 2013 at 21:01
  • use noabbrev like so: \usepackage[noabbrev]{cleveref}
    – Scriddie
    Commented Sep 8, 2021 at 19:42

5 Answers 5

31

Short answer

\usepackage[noabbrev,nameinlink]{cleveref}

Long answer

Is there a way of changing that without manually changing all the crefnames? There doesn’t seem to be an appropriate option.

According to the manual:

The default cross-reference names for some languages use common abbreviations for some of the names (e.g. in the default English format, \cref{eq1} will be typeset as eq.~(1)). Some authors may prefer to always use the full name, rather than an abbreviation (equation~(1) instead of eq.~(1)). To disable all use of abbreviations in the default cross-reference names, pass the noabbrev option to the cleveref package

To your second question:

Furthermore, when used in conjunction with the hyperref package, only the number is actually linked. The text in front of it (“figure” in my example) isn’t. Can this also be changed (again, without redefining all the commands)?

According to the manual:

When using the hyperref package, cleveref automatically makes all cross- references into hyperlinks to the corresponding reference. By default, only the label itself forms part of the hyperlink target (i.e. the text you can click on to nav- igate to the cross-reference). The cross-reference name is not part of the hyperlink. By contrast, hyperref’s \autoref command does includes the name as part of the hyperlink. If you prefer to include the names in the hyperlinks when using cleveref, you can pass the nameinlink option to the cleveref package.

2
  • 2
    Regarding the OP's second question: In order to get the item's name become part of the hyperlink, it suffices to specify the option nameinlink when loading the cleveref package. (This option has been around for at least two years.)
    – Mico
    Commented Sep 7, 2014 at 10:10
  • 1
    Didn't know that. Strange that this question is 4 years old, one of the first hits in google, all the options are available since >2 years, but i'm the first to formulate the (now) correct answer. Commented Sep 7, 2014 at 10:18
24

There is a new pre-release version (v0.18) of cleveref which supports a noabbrev option which does this automatically. The new version is not yet on CTAN but can be downloaded on the package author's website: http://www.dr-qubit.org/latex.php#cleveref

1
  • 5
    By now this new version has been released to CTAN. (In fact the CTAN version is now at v0.18.4 and the pre-release at qubit's website is at v0.18.5.)
    – Matthias
    Commented Mar 7, 2012 at 17:35
12

Hm, there indeed seems to be no option for non-abbreviation, which is annoying, because \Cref does it, only along with capitalization. Looking briefly at the source, we at least have a convenient list I ran through "lowercase selection":

 \AtBeginDocument{%
    \crefname{equation}{equation}{equations}%
    \crefname{chapter}{chapter}{chapters}%
    \crefname{section}{section}{sections}%
    \crefname{appendix}{appendix}{appendices}%
    \crefname{enumi}{item}{items}%
    \crefname{footnote}{footnote}{footnotes}%
    \crefname{figure}{figure}{figures}%
    \crefname{table}{table}{tables}%
    \crefname{theorem}{theorem}{theorems}%
    \crefname{lemma}{lemma}{lemmas}%
    \crefname{corollary}{corollary}{corollaries}%
    \crefname{proposition}{proposition}{propositions}%
    \crefname{definition}{definition}{definitions}%
    \crefname{result}{result}{results}%
    \crefname{example}{example}{examples}%
    \crefname{remark}{remark}{remarks}%
    \crefname{note}{note}{notes}%
}

but I agree that it's clumsy.

2
  • 2
    According to the cleveref documentation, the user interface command is \crefname rather than the internal name \crefname@preamble.
    – Lev Bishop
    Commented Dec 24, 2010 at 0:21
  • This answer ought to be updated to reflect the creation of the options noabbrev (to suppress abbreviation of the items' names) and nameinlink (to include the items' names in the hyperlink).
    – Mico
    Commented Sep 7, 2014 at 10:13
1

Furthermore, when used in conjunction with the hyperref package, only the number is actually linked. The text in front of it (“figure” in my example) isn’t. Can this also be changed (again, without redefining all the commands)?

I’ve thrown together the following macro to change this. I’m not particularly satisfied since I still need to maintain a list of all label types but this is the best I got:

\newcommand*\@cref@format[1]{%
  \crefformat{#1}{##2\@nameuse{cref@#1@name}~##1##3}%
  \Crefformat{#1}{##2\@nameuse{Cref@#1@name}~##1##3}}

\newcommand*\@labeltypes{
  algorithm,
  appendix,
  chapter,
  corollary,
  definition,
  enumi,
  equation,
  example,
  figure,
  footnote,
  lemma,
  line,
  note,
  part,
  proposition,
  remark,
  result,
  section,
  table,
  theorem}

\@for\@i:=\@labeltypes\do{%
  \trim@spaces@in\@i
  \expandafter\@cref@format\expandafter{\@i}}

This requires the trimspaces package.

3
  • This answer needs to be updated to reflect the availability of the package option nameinlink.
    – Mico
    Commented Sep 7, 2014 at 10:15
  • @Mico Actually the "correct" thing would be for you to write a new answer which reflects the new option. ;-) Commented Sep 7, 2014 at 11:11
  • By now, this posting has already attracted five answers; I'd rather not add a sixth...
    – Mico
    Commented Sep 7, 2014 at 11:29
1

We don't seem to need the \Crefformat part of the above definition by Konrad. I suggest the following.

\usepackage{catoptions}
\usepackage{hyperref}
\usepackage{cleveref}[2011/03/22]
% \makeatletter
\def\setupcrefformat{%
  \docommalist{algorithm,appendix,chapter,corollary,definition,
    enumi,equation,example,figure,footnote,lemma,line,note,part,
    proposition,remark,result,section,table,theorem
  }{%
    \crefformat{##1}{####2##1~####1####3}%
    % We don't seem to need the following:
    % \Crefformat{##1}{####2\@nameuse{Cref@##1@name}~####1####3}%
  }%
}
% \makeatother
\setupcrefformat

\docommalist trims leading and trailing spaces around the list elements.

1
  • This answer ought to be updated to reflect the availability of the package noabbrev.
    – Mico
    Commented Sep 7, 2014 at 10:14

You must log in to answer this question.

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