In case of multiple cross-references of same kind (say sections), even if not consecutive, cleveref
's \cref
command compresses the references' labels by using the plural form: for instance, \cref{foo2,foo4,foo6}
could prints:
sections 2, 4 and 6
instead of:
section 2, section 4 and section 6
If varioref
is also loaded, the page numbers can be added thanks to its \vref
command (redefined by cleveref
) used instead of \cref
.
But, then, the "page" label is not compressed, as shown by the following MWE where \vref{foo2,foo4,foo6}
prints:
sections 2, 4 and 6 on page 4, on page 8 and on page 12.
where one could expect:
sections 2, 4 and 6 on pages 4, 8 and 12.
especially since:
\cpageref
does the right job,cleveref
's documented code claims to use\cpageref
instead of\vpageref
in its redefinition of\vref
:Since
\cref
can cope with multiple references, we extend the page referencing magic of\vref
et al. to use\cpageref
instead, assisted by\@setvpageref
and\@vpagerefrange
(which typeset page references usingvarioref
commands). The former takes care of multi-references, the latter take care of thevarioref
page referencing magic.
Do you see what's going on?
\documentclass{article}
\usepackage{multido}
\usepackage{varioref}
\usepackage{cleveref}
%
\newcommand{\test}[1]{%
\section{#1}\label{#1}
\newpage
#1
\newpage
}
%
\begin{document}
\begin{itemize}
\item \verb|\cref{foo2,foo4,foo6}|: \cref{foo2,foo4,foo6}
\item \verb|\vref{foo2,foo4,foo6}|: \vref{foo2,foo4,foo6}
\item \verb|\cpageref{foo2,foo4,foo6}|: \cpageref{foo2,foo4,foo6}
\item \verb|\vpageref{foo2,foo4,foo6}|: \vpageref{foo2,foo4,foo6}
\end{itemize}
\newpage
\multido{\i=1+1}{6}{%
\test{foo\i}
}
\end{document}
\vref
need to be redefined in some way to be\cref{#1} on \cpageref{#1}
. I think the best is to write to the author.cleveref
tag ;)