This question is a development of the same issue as this one; following my own answer and later comment there, I decided it deserves a spin-off.
I would like to define an environment for restating theorems(/lemmata/propositions/etc), which makes the following code work:
\documentclass{article}
\usepackage{ntheorem}
% Magic goes here
\newtheorem{theorem}{Theorem}[section]
\newtheorem{prop}[theorem]{Proposition}
\begin{document}
\begin{theorem}\label{myfirst}
This is the first environment.
\end{theorem}
\begin{prop}\label{mysecond}
This is the second environment.
\end{prop}
\begin{theorem}\label{mythird}
This is the third environment.
\end{theorem}
\clearpage
\begin{restatement}[restated]{mysecond}
\label{mysecond-restated}
This is a restatement of the second environment.
\end{restatement}
\begin{theorem}\label{myfourth}
This is the fourth environment.
\end{theorem}
a \verb|ref| to the second environment: \ref{mysecond} \
a \verb|ref| to its restatement: \ref{mysecond-restated} \
a \verb|pageref| to the second environment: \pageref{mysecond} \
a \verb|pageref| to its restatement: \pageref{mysecond-restated}
\end{document}
Requirements:
- The environment only requires the label of the theorem you're referencing, nothing else.
- You should be able to reference the restatement rather than the original statement.
- You can't assume the environment's counter has the same name as the environment (e.g. the user may have
\newtheorem{proposition}[theorem]{Proposition}
, so propositions use the theorem counter).
Optional, Nice-to-Have features:
- No reliance on
hyperref
,cleveref
orthmtools
. (This was "Requirement 5" which the bounty mentions) - Code which works with
amsthm
as well. \autoref
ing or\namecref
ing the restatement work whenhyperref
orcleveref
are used.- Code doesn't break when writing right-to-left documents (Hebrew, Arabic)
- Possibility of restating unnumbered theorems.
An initial solution
My initial work has evolved into a basically-satisfactory solution, see below, with the help I got asking lead-up questions. But that solution suffers from several problems:
The problems with this are:
- I have no idea what
\cref@constructprefix
inntheorem
does, and what's the intended use ofp@somecounter
, so I basically copy-pasted that part blindly and maybe I'm doing something wrong. - The code is already not so short.
- Code likely to break if
cleveref
orntheorem
change slightly.
And it does not meet most of the useful want-to-have's above. So improvements are quite welcome for your bounty!
Best Answer
Well, with a little help from friends in other questions (this one and this one, it looks like I have a solution satisfying the basics:
Edit: Now supporting hyperref, but for that we need counter aliasing, see this question for the reason we need that.