# can I fix the following problem with multiple theorem statement?

I am using the theomac.sty file for being able to have the same theorem appear in several different places in the .tex file without having to copy it, and while still having the same numbering (so for example, the theorem statement can appear in a certain section, and then the proof can appear in an appendix with the statement of the theorem again).

The way it works is by using the following:

\begin{replemma}[\lemmaC]
lemma here
\end{replemma}


Then, whenever I want to paste the lemma again, I can use \lemmaC.

replemma is defined in the beginning of the .tex file as:

\let\replemma=\lemma
\let\endreplemma=\endlemma
\makeatletter
\@newtheoremWithMacro{replemma}{lemma}%
\makeatother


The problem I am having is two-folded. 1. If I have a footnote in the first appearance of the theorem, then this footnote is added every time I use \lemmaC. Still, I want the footnote to appear only in the first instantiation. 2. If I refer to an equation that appears in the lemma, then the equation is preceeded with the section number of the last appearance, instead of the first appearance (I use equations numbered with section). This means that everywhere I refer to an equation appearing in the lemma, it appears with an appendix prefix A.2 for example, instead of 4.2 (it first appears in section 4). Any ideas how to fix these two problems?

As egreg has mentioned, the thmtools package lets you handle both problems easily (refer to Section 1.4 Repeating theorems of the documentation). A little example:

\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage{thmtools,thm-restate}

\declaretheorem{theorem}
\numberwithin{equation}{section}

\begin{document}

\noindent\begin{minipage}{\textwidth}% just for the example
\section{Test section one}

\begin{restatable}{theorem}{lastfermat}
\label{thm:fermat}%
The Diophantine\footnote{after  Diophantus of Alexandria} equation
$$\label{eq:1} x^n + y^n = z^n,$$
where $x$, $y$, $z$, and $n$ are integers, has no nonzero solutions for  $n>2$.
\end{restatable}

\section{Test section two}

{\renewcommand\footnote[1]{}\lastfermat*}

Equation~\ref{eq:1} in Theorem~\ref{thm:fermat}...
\end{minipage}

\end{document}


Notice the braces enclosing the redefinition of \footnote, to keep it local. I used a minipage only to shorten the example.

I don't know about theomac; but surrounding the repetition with

\begingroup\renewcommand\footnote[1]{}
<the commands for repeating the theorem>
\endgroup


should neutralize the effect.

Consider using the very powerful package thmtools.