# Pagenumber within \cref command


\renewcommand{\cref}[1]{\namecref{#1} \labelcref{#1} (\cpageref{#1})}


but I have also some references to more than one label. The problem with this renewcommand is that \nameref{} takes only one label and so after the change I get some "??" in my document. I could possibly go through the whole document again and add the page ref everywhere it is needed, but this would take a lot of time and I would appreciate it, if there would be a more easy way. It would also be great if the page ref could only be given if the label is on a different page than the cross-reference call-out (if this is even possible). I've searched the Internet now for quite a while and didn't find an answer to this problem.

Thanks in advance for your efforts

PS: the document class is article:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsthm}
\usepackage{cleveref}

\newtheoremstyle{thm}   {\topsep}{\topsep}{\itshape}{-0.25em}{\bfseries}{}{0.5em}{}
\theoremstyle{thm}
\newtheorem {theorem}   {Theorem}[section]

\Crefname{theorem}{theorem}{theorems}
\crefname{theorem}{theorem}{theorems}

\begin{document}
\section{Something}
\begin{theorem}
\label{Theorem_1}
Some theorem.
$$a^2+b^2=c^2\label{eq:1}$$
\end{theorem}
maybe some other text
\begin{theorem}
\label{Theorem}
Soem other theorem.
\end{theorem}
A reference to \cref{Theorem} everything is great
\newpage
If I put a reference here to \cref{Theorem_1} I would prefer it would be like \cref{Theorem_1} (\cpageref{Theorem_1}).
\end{document}

• Welcome to TeX.SE! Please show us a short compilable code we can play with ... – Kurt Jan 23 at 10:12
• You should capitalise theorem and Theorems in the second and third argument of \Crefname. Otherwise the word won't be capitalised if you use \Cref (at the start of a sentence, say). Incidentally, you don't even have to declare the theorem environment since cleveref already knows about theorems, lemmas (unless you prefer lemmata as a plural), corollaries, definitions, propositions, results, examples, remarks and notes. – Circumscribe Jan 23 at 11:07
• I wasn't shure what I need to declare and what I don't. I write the skript in german and in the script I declared everything the way I need it. This was just for the example but thats not really the matter. But thanks for the mention :) – Kai Jan 23 at 13:03

## 1 Answer

The varioref package and its \vref macro pretty much do what you're looking to accomplish.

Note that if both varioref and cleveref are loaded, varioref must be loaded before cleveref. If both packages are loaded, the command \vref acts very much like \cref, except that it automatically inserts a page number reference (as well as the main cross-reference) whenever the call-out and the cross-referenced item aren't located on the same page.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsthm}
\usepackage{varioref}
\usepackage{cleveref}

\newtheoremstyle{thm}   {\topsep}{\topsep}{\itshape}{-0.25em}{\bfseries}{}{0.5em}{}
\theoremstyle{thm}
\newtheorem{theorem}{Theorem}[section]

%\Crefname{theorem}{theorem}{theorems}
%\crefname{theorem}{theorem}{theorems}

\begin{document}
\setcounter{section}{1}

\begin{theorem} \label{Theorem_1}
Some theorem.
$$a^2+b^2=c^2\label{eq:1}$$
\end{theorem}
Maybe some other text
\begin{theorem}\label{Theorem_2}
Some other theorem.
\end{theorem}

A cross-reference to \cref{Theorem_2}---everything is great.

\newpage \null \newpage

I would like a cross-reference of the form \vref{Theorem_1}''.
\end{document}

• Thanks this looks like what i want. But with this solution I still have the problem that I have to go through over 100 output pages again and need to change every \cref to a \vref. And my sourcecode is in multiple parts so i would also need to change those all the time. If there isn't a nice way to reach what I want I just might have to do this but I would prefer an easy global solution in wich I dont have to change every single reference. – Kai Jan 23 at 12:32
• @Kai - Since i have virtually no information about the structure of your document, it's not possible for me to make a recommendation for how you should organize your document's cross-references. If this were my document, I would either replace \cref with \vref for the most important theorems only or, more likely, load the hyperref package, automatically making all cross-reference call-outs into hyperlinks to the corresponding targets. (If you go this route, be sure load varioref first, hyperref second, and cleveref third, i.e., last.) – Mico Jan 23 at 13:03
• I have the hyperref loaded and in use. But I prefer to lern with a printed script and in this case I have to search pretty much. But thanks for the help and if nothing else comes up I will go through the whole document. I just thougth I ask incase someone already had this problem and found a good and easy solution. Thank you for taking the time to help me :) – Kai Jan 23 at 13:08
• If you absolutely must, you can redefine \cref to behave as \vref* (the starred version is preferable, see the documentation) with \renewcommand*\cref{\vref*}. Doing a global search-and-replace doesn't seem like it should be that difficult though. If you need to store the original \cref you should use \LetLtxMacro. – Circumscribe Jan 23 at 15:31
• @Mico I desided to take your method and change the ´\cref´ to ´\vref´...this isn't as much work as I thought thanks to the search mechanism in TeX-Maker. Thanks a lot :) – Kai Jan 23 at 15:37