I am writing a script for a lecture in math and have quite a few cross-references in it. Now i have the problem, that the cross-references are sometimes pretty far away from the theorems they refer to. I would like to have a way (by options of the cleveref
package or a renewcommand for \cref
) to put the page number into the output of \cref
. I've alredy tried a \renewcommand
like
\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.
\begin{equation}
a^2+b^2=c^2\label{eq:1}
\end{equation}
\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}
theorem
andTheorems
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 sincecleveref
already knows about theorems, lemmas (unless you prefer lemmata as a plural), corollaries, definitions, propositions, results, examples, remarks and notes.