## Monday, June 19, 2017

### A bit of TeX hacking

I've decided that if I state, say, Theorem 2.2.15 but don't prove it until many pages and lemmas later in Section 5, then, for the reader's sake, I should repeat the theorem verbatim, including the original theorem number, immediately before the proof, as opposed to going straight from the proof of Lemma 5.2.33 to "Proof of Theorem 2.2.15." (Granted, if the delay between statement and proof is just for one "Main Theorem" whose statement is easy to remember, then this is not necessary. My decision is in the context of revising a longer paper with several theorems stated early and proved much later.)

%#1 theoremstyle inpute (plain/definition/remark/...)
%#2 type of theorem (Theorem/Lemma/Corollary/...)
%#3 label of theorem to be repeated
%#4 unique new input for \newtheorem
%#5 statement of theorem
\def\repeattheoremhelper#1#2#3#4#5{
\theoremstyle{#1}
\newtheorem*{#4}{#2 \ref{#3}}
\begin{#4}
#5
\end{#4}
}

\def\repeattheorem#1#2{
\repeattheoremhelper{plain}{#1}{#2}{repeat#2}{\csname state#2\endcsname}
}

%usage example
%\theoremstyle{plain}
%\newtheorem{thm}{Theorem}
%...
%\def\statemytheorem{blah blah}
%\begin{thm}\label{mytheorem}\statemytheorem\end{thm}
%...
%\repeattheorem{Theorem}{mytheorem}
%\begin{proof}
%...
%\end{proof}