[Tex/LaTex] Put the proof in appendix, with links between theorem and proofs


I would like to be able to add some proofs of my document in appendix. I like the solution "New Version" given here, but I would like in addition to have:

  1. A text below the theorem that write something like "Please, find the proof of this theorem in appendix".
  2. Add a link from this text to the proof
  3. Add another link from the proof title to the theorem
  4. If possible recall the theorem just above the proof

For example it would looks like, in pseudo-generated-code:

Theorem 1.1
  1 = 1
Please find the \hyperlink{th1.1}{proof of this theorem} in appendix.
[... lot's of stuff ...]

Theorem 1.1
  1 = 1
Proof of \autoref{th1.1}

I tried to change by myself the code of the above answer, but I'm not familiar enough with tex syntax, and I'm getting stuck on point 3 with link that point nowhere (I suspect bugs with the expandafter, but I don't know how to debug my code).

Thank you for your help !

Best Answer

I found a first solution, that seems to work for points 1,2,3, but not for 4 : I don't know how to change the environment of theorem (\begin{theorem} must be transform in \begin{restatable}[]{theorem}{} EDIT : it seems that adding an option restate=foo is enough, but I don't know how I could add such an option... I tried to set \xdef\pat@restate{foo} but it doesn't work... Any idea ?).


% We define an addition for the theorem-like environments; when
% \newtheorem{thm}{Theorem} is declared, the macro \thm expands
% to {...}{...}{...}{Theorem} and with \@fourthoffour we access
% to it; then we make available \@currentlabel (the theorem number)
% also outside the environment.

\newcommand\fixstatement[2][\proofname\space of]{%
  \ifcsname thmt@original@#2\endcsname
    % the theorem has been declared with \declaretheorem
        \@fourthoffour\csname thmt@original@#2\endcsname\space\@currentlabel}%
    % the theorem has been declared with \newtheorem
        \@fourthoffour\csname #1\endcsname\space\@currentlabel}%

% We allocate a block of 1000 token registers; in this way \prooftoks
% is 1000 and we can access the following registers of the block by
% \prooftoks+n (0<n<1000); we'll use a dedicated counter for it
% that is stepped at every proof

% We gather the contents of the proof as argument to \proofatend
% and then we store
% "\begin{proof}[Proof of <theoremname> <theoremnumber>]#1\end{proof}"
% in the next token register of the allocated block
  You can find \hyperlink{proofatend:\pat@uniqlabel}{the proof} at the end of the paper.
  % [\textbf{thm_fix:\pat@uniqlabel}]\hyperlink{thm_fix:\pat@uniqlabel}{Ahah}\\
    % \noexpand\begin{proof}[\pat@proofof\space\pat@label]%

% \printproofs simply loops over the used token registers of the
% block, freeing their contents

% Here starts the example, with two theorem declarations
\fixstatement[Demonstration of]{lem}

It's quite clear. \Blindtext
Obvious from lemma. \Blindtext


Related Question