I have some custom cross-references that need labels that are not naturally linked to counters. My macros therefore set \@currentlabel directly instead of using \refstepcounter. This works fine but cleveref is not able to understand the type of these references (unless one specifies a custom type for each affected \label).

I have seen questions where redefining \cref@currentlabel managed to get cleveref informed of the right format to use but it is not clear what is the arguments specification that the package is expecting to be used. From bits and pieces, the redefinition seems to follow a scheme similar to

  The typeset label}

So my question is: how is one supposed to communicate to cleveref that the current label is a custom one, with custom type mytype? How is \cref@currentlabel supposed to be redefined?

  • cleverref always complains about unknown types, i.e. the if you use foo as type, and do not specify the corresponding \crefformat{foo}{#2#1#3} it will choke otherwise your approach should work
    – user31729
    Commented Dec 29, 2016 at 15:25
  • I think the crucial point is the macro ` \cref@constructprefix{#1}{\cref@result}`
    – user31729
    Commented Dec 29, 2016 at 16:04
  • @ChristianHupfer it's ok if I need to instruct cleveref on how to handle the custom type. My issue is: how to signal which type I want it to use, if I am bypassing \refstepcounter?
    – Bordaigorl
    Commented Dec 29, 2016 at 16:19
  • I have no fully working solution yet
    – user31729
    Commented Dec 29, 2016 at 16:20

1 Answer 1


cleveref is a very clever package, but hard to understand as it has many windings inside.

The easiest way, in my point of view, is to use \label[type]{labelname} Funny enough, type does not need to be a counter at all, but \cref@currentlabel must be defined as has been done by the O.P. already.

The value in the second [...] inside of the \cref@currentlabel{...} has usually the value of the counter, this is not important here, so I left it empty.

The \crefname and \Crefname macros should be called to inform cleveref about the type name.







\crefname{footext}{some foo text}{some foo texts}
\Crefname{footext}{Some Foo text}{Some foo texts}


\section{My section} \label{secone}

Here is the link target: \arblabel{foo}{This is a nice foo text}


\cref{foo} or rather like \Cref{foo}?

  • Thanks for this. Followup question: is the value of the counter (left empty here) used for sorting? Would this create unwanted effects when using \cref{foo1,foo2}? And what does \cref@result do? And constructprefix?
    – Bordaigorl
    Commented Dec 29, 2016 at 17:49
  • @Bordaigorl: I have to check...
    – user31729
    Commented Dec 29, 2016 at 17:51
  • I guess you want a \phantomsection too?
    – Bordaigorl
    Commented Dec 29, 2016 at 17:54
  • It is a pity that this is not documented, cleveref is such a nice package...
    – Bordaigorl
    Commented Dec 29, 2016 at 17:55
  • 1
    So the \arblabel definition could be simplified to just: \protected@edef\cref@currentlabel{[#1][][]#3}% \label[#1]{#2}% Commented Jun 11, 2017 at 18:00

You must log in to answer this question.

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