# \cpageref from cleveref produces wrong label

The code that follows

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}

\begin{document}

\begin{figure}[!htbp]
%
\caption{Sample.}
\label{fig:sample}
%
\centering
%
Some nice picture goes here.
%
\end{figure}

Some text referring to the stuff on \cpageref{fig:sample}.

\end{document}


Produces the result:

Is this a bug in the cleveref package or am I missing something completely obvious?

• Yes, this is apparently a bug introduced in the latest version. The version from 2013 works as expected – user31729 Feb 16 '18 at 21:44
• For now, I just re-defined the command: \def\cpageref{\myownpagecommand} Does this seem like a reasonable solution? My goal is to be able to remove that line when the bug has been fixed. – dow Feb 16 '18 at 21:57

There is a bug in cleveref 0.21.1 from 2018/02/08. The version 0.19 from 2013 works as expected.

A small workaround extracts the hyper anchor with refcount features (loaded by hyperref anyway).

\documentclass[english]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}

\renewcommand{\cpageref}[1]{%
\IfRefUndefinedExpandable{#1}{}{%
}%
}

\begin{document}

\begin{figure}%[!htbp]
%
\caption{Sample.} \label{fig:sample}
%
\centering
%
Some nice picture goes here.
%
\end{figure}

Some text referring to the stuff on \cpageref{fig:sample}.

\end{document}

• How about \newcommand*{\mypageref}[1]{page~\pageref{#1}} followed by \def\cpageref{\mypageref}? – dow Feb 16 '18 at 22:14
• @dow: Also possible... but in general, you should use \renewcommand etc.... -- your solution would not put the Page in the link, however, which was an option you used with nameinlink – user31729 Feb 16 '18 at 22:15

Fixed in the latest pre-release (currently v0.21.3), available from my web site.

Please note that Stackexchange is not a bug tracker. Post questions to SE; report bugs via the software's normal bug-reporting channel. (Plain old email to the address given in the package docs for cleveref; bugzilla/github/trac/whatever-bug-tracker-it-uses for more sophisticated software.)

Bug reports are as valuable a part of free software development as code contributions. By all means ask about it on SE first, but don't forget to submit a proper bug report too! Otherwise they risk languishing on SE unnoticed, unloved and unfixed.

• Thanks for fixing! By the way, did you change the way how the arguments in in your \newlabel{foo@cref}{....} macros are stored? – user31729 Feb 17 '18 at 21:51
• You are right, I should not have omitted submitting a bug report after confirming on SE. Thanks for the follow up! – dow Feb 17 '18 at 22:50
• @ChristianHupfer Yes, the '\newlabel's now store additional page reference data. The '\newlabel' format is an internal implementation detail, and has changed from time to time. However, the '\cref@getlabel', '\cref@getprefix' etc. (and now '\cpageref@getlabel' etc.) accessor macros for extracting this data have been there almost since v0.1, and get updated when the format changes. I'm not going to make any promises about maintaining full backwards compatibility forever, but if you need to access the cleveref data those accessor macros are probably the safest bet. – Toby Cubitt Feb 24 '18 at 9:08
• @TobyCubitt: Thank you for the information. If I have known about \cref@getlabel etc. I would not have written crossreftools as a separate package, most likely. May I suggest to mention those macros in the manual? – user31729 Feb 24 '18 at 13:21
• @MdAyquassar Apologies, it should have read version 0.21.3, which was the latest version when I posted that answer. Since then I've released version 0.21.4, which is also available on CTAN now. – Toby Cubitt May 5 '18 at 20:34