\documentclass{article}

\usepackage{amssymb, amsthm, amsmath}
\usepackage{hyperref}
% Load the package (put the proof-at-the-end.sty file in the working directory)
\usepackage{proof-at-the-end} % with default options...
% Or by putting in the 'conf' option the default configuration you want:
%\usepackage[conf={normal, one big link}]{proof-at-the-end}
%\usepackage[conf={normal, one big link=Goto proof}]{proof-at-the-end}
%\usepackage[conf={one big link translated=Aller à la preuve page}]{proof-at-the-end}
%\usepackage[conf={text link section}]{proof-at-the-end}

%%% If you want to use options with macros, you cannot
% use directly the package options, so just modify
% the global custom defaults like that:
% \pgfkeys{/prAtEnd/global custom defaults/.style={
%     text link={\hyperref[proof:prAtEnd\pratendcountercurrent]{See proof on page~\pageref*{proof:prAtEnd\pratendcountercurrent}}}
%   }
% }
%%% You can also easily modify the gloabl/locals defaults in other parts of the code using:
% \pgfkeys{/prAtEnd/local custom defaults/.style={
%     category=greattheorem
%   }
% }
%%% Or create new styles to apply:
% \pgfkeys{/prAtEnd/great category/.style={
%     category=greattheorem
%   }
% }

%% Define your theorem/lemma/... environments the way you want:
% Theorems
\newtheorem{thm}{Theorem}[section]
\newtheorem*{thm*}{Theorem}
\providecommand*\thmautorefname{Theorem}
% Lemmata
\newtheorem{lemma}[thm]{Lemma}
\newtheorem*{lemma*}{Lemma}
\providecommand*\lemmaautorefname{Lemma}

%% If you want you can define shortcuts:
\usepackage{xparse}
% And to define new shortcuts:
\NewDocumentEnvironment{mynormalthm}{O{}O{}+b}{%
  \begin{theoremEnd}[normal,#2]{thm}[#1]%
    #3%
  \end{theoremEnd}%
}{}

\begin{document}

\section{Demo of proof-at-the-end}

NB: This file is just a demo of proof-at-the-end.  You can find the documentation, sources, and example of proof-at-the-end at \url{https://github.com/leo-colisson/proof-at-the-end}. Note that this file is getting a bit big but it should contain more or less everything that is possible in this lib as it's also used to ``test'' the library.

% And use \theoremProofEnd[<package options>]{theorem environment name}[Title]{Theorem}{Optional proof}
\begin{theoremEnd}{thm}[Yes I can have a title]
  \label{thm:ilikelabels}
  Simplicity is luxury, I am a default theorem.
\end{theoremEnd}
\begin{proofEnd}
  Let's be simple.  
\end{proofEnd}

And I can refer to my theorems using classic labels, like in \autoref{thm:ilikelabels}.

\begin{theoremEnd}[text link section]{thm}[Changing link]
  It is possible to change the link.
\end{theoremEnd}
\begin{proofEnd}
  Here I'm using ``text link section''.
\end{proofEnd}

\begin{theoremEnd}[category=greattheorem, end]{thm}[Different categories]
  You can also create several categories, and put the proofs in different sections.
  \[2\Delta = \Delta + \Delta\]
\end{theoremEnd}
\begin{proofEnd}
  See, I am in another section! And I refer to \autoref{thm:ilikelabels} even in the proof.
\end{proofEnd}

\begin{theoremEnd}[restate]{thm}[I am restatable]
  I am a restatable theorem, go in Appendix you will see ;-)
\end{theoremEnd}
\begin{proofEnd}
  I am a proof of a restatable theorem.  
\end{proofEnd}


\begin{theoremEnd}[normal]{thm}
  You can easily turn it back into a normal theorem!
\end{theoremEnd}
\begin{proofEnd}
  And keep the proof with you!  
\end{proofEnd}

You can also put comments that appear only in the appendix.

\textEnd{See, I am a simple comments with math $\delta = b^2-ac$ and references \autoref{thm:mytheoremattheend}.}

\begin{textAtEnd}
  You can also use the environment syntax.
\end{textAtEnd}

\textEnd[both]{Or that appears in both and with references \autoref{thm:mytheoremattheend}!}

\begin{theoremEnd}[proof here]{thm}
  And you can duplicate the proof, here AND in appendix ;)  
\end{theoremEnd}
\begin{proofEnd}
  I am a proof that is everywhere, practical if you want to use synctex while you write the proof ;)
\end{proofEnd}

\begin{theoremEnd}{lemma}
  You can mix it with lemmas... Or any other theorem-like environment easily!  
\end{theoremEnd}
\begin{proofEnd}
  See, I'm the proof of a lemma!  
\end{proofEnd}

And also you can put both the theorem and the proof at the end, like for \autoref{thm:mytheoremattheend}!

\begin{theoremEnd}[all end]{thm}
  \label{thm:mytheoremattheend}
  $\delta = b^2-4ac$
  You can also put theorems only at the end.  
\end{theoremEnd}
\begin{proofEnd}
  See, I'm the proof of a lemma that is only at the end!
\end{proofEnd}


You can also remove the link to the theorem:
\begin{theoremEnd}[no link to theorem, restate]{thm}
  I don't like links in proofs.  
\end{theoremEnd}
\begin{proofEnd}
  Yes, I like being lost, but not too lost, so I prefer to restate as well!
\end{proofEnd}

Or keep the link, but remove the reference (practical for stared versions):
\begin{theoremEnd}[stared]{thm*}
  I don't like numbers.
\end{theoremEnd}
\begin{proofEnd}
  Yes, I hate numbers, but I like links.
\end{proofEnd}


\pgfkeys{/prAtEnd/french/.style={
    one big link translated={Voir preuve page},
    text proof translated={Preuve du}
  }
}
\begin{theoremEnd}[french]{thm}%% See how "french" is defined just above
  Change the text/languages of the link: Il est même possible de changer la langue du texte du lien!  
\end{theoremEnd}
\begin{proofEnd}
  Si c'est pas beau ;)
\end{proofEnd}

And of course it is easy to define custom shortcuts, using in prelude:
\begin{verbatim}
\NewDocumentEnvironment{frenchthm}{O{}+b}{%
  \begin{theoremEnd}[french]{thm}[#1]%
    #2%
  \end{theoremEnd}%
}{}
\end{verbatim}

\begin{mynormalthm}[My own environment]
  You can then create your own environment from other styles using
\end{mynormalthm}
\begin{proofEnd}
  That's quicker :D
\end{proofEnd}

\begin{mynormalthm}[My own environment][end]
  You can use options also with your custom environments.
\end{mynormalthm}
\begin{proofEnd}
  That's quicker with the proof at the end :D
\end{proofEnd}

\begin{mynormalthm}[][end]
  And you can remove the title and have options.
\end{mynormalthm}
\begin{proofEnd}
  Just leave empty title.
\end{proofEnd}

\begin{mynormalthm}[My second own environment][all end]
  My normal theorem is moved at the end!
\end{mynormalthm}
\begin{proofEnd}
  Custom environments are practical no ;)
\end{proofEnd}

\begin{theoremEnd}[]{thm}[Yes I can have no proof]
  Proof is useless. You can do do it. And see, I can include other environments inside me ;)\\
  \begin{tabular}{ c c } 
    A & B \\ 
    C & D \\ 
  \end{tabular}
\end{theoremEnd}


\begin{theoremEnd}[restate command=mymanualrestate]{thm}[Manual restate]
  A theorem can be manually restated  
\end{theoremEnd}
\begin{proofEnd}
  Use restate command for that! (see \autoref{sec:manualrestate} for an example)
\end{proofEnd}

\begin{theoremEnd}[see full proof]{thm}
  I can also write a sketch of proof, and put the full proof in appendix.
\end{theoremEnd}
\begin{proof}
  Hint: look at the alias options.
\end{proof}
\begin{proofEnd}
  You just use ``see full proof'' as an option
\end{proofEnd}

It should also deal with protected commands: $\mathtt{mathtt}$:
\begin{theoremEnd}[end]{thm}[Title $\Delta$ et $\mathtt{Gad}$]
  You can use commands that should be protected $\mathtt{See}$!
\end{theoremEnd}

\begin{theoremEnd}[end]{thm}[Deal with paragraphs]
  You can have a theorem

  with several paragraphs.
\end{theoremEnd}
\begin{proofEnd}
  And I also like to have big proofs.
  
  With several paragraphs.
\end{proofEnd}

\section{Section with restate before theorem}\label{sec:restatebefore}

\begin{theoremEndRestateBefore}{thm}[Title]{laterrestatable}
  \label{thm:laterrestatable}
  This theorem has been introduced in \autoref{sec:restatebefore} before the real definition, but the real definition is in \autoref{sec:restateafter}, more precisely here: \autoref{thm:laterrestatable}.
\end{theoremEndRestateBefore}


\begin{theoremEnd}{thm}
  And this is a normal theorem  
\end{theoremEnd}
\begin{proofEnd}
  With a normal proof  
\end{proofEnd}


\section{Section with late theorems}\label{sec:restateafter}
\begin{theoremEnd}[restated before]{thm}
  laterrestatable
\end{theoremEnd}
\begin{proofEnd}
  To state a theorem before the initial definition, use theoremEndRestateBefore environment where you first want to state the theorem, with a unique name in the second mandatory argument, and when you want to insert the theorem for the second time, use the usual theoremProofEnd command with the same unique name as before in place of the theorem definition and the ``restated before'' option.  
\end{proofEnd}

\section{Section with standard proofs}
% \verbatiminput{defaultcategory}
\printProofs

\section{Section with important proofs only}
\printProofs[greattheorem]

\section{Section with manual restate}\label{sec:manualrestate}

I like to manually restate theorems:
\mymanualrestate*


\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
