I would like to re-use equations with the same content and number. I know that the thmtools
package has a restatable
environment to do this for environments (like in this answer), but I would also like to do this with a single equation that is only part of some environment.
I had a look at the following questions which only aim at repeating the equation number but typing the whole equation twice (the first three) or repeat the content of the equation without a number (the last one):
- repeating an equation and getting the same equation number?
- Using the same number for repeated use of the same equation
- Repeat a previously labelled equation without changing the label
- How to use macros to repeat math equations in different settings
Based on the answers provided there and on the last part of this answer I tried to create a macro \restatableeq
for restable equations like this:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\restatableeq}[3]{\label{#3}#2\xdef#1{\unexpanded#2\unexpanded\tag{\unexpanded\ref{#3}}}}
\begin{document}
\begin{eqnarray}
\restatableeq{\eqone}{This & is & eqation 1}{eq1}\\
Another & simple & equation
\end{eqnarray}
\begin{eqnarray}
One & more & equation\\
\restatableeq{\eqtwo}{This & is & eqation 2}{eq2}
\end{eqnarray}
Here, we use (\ref{eq1}) and (\ref{eq2}) again:
\begin{eqnarray*}
\eqone\\
\eqtwo
\end{eqnarray*}
\end{document}
Unfortunately, it does not work and yields:
! Missing { inserted.
<to be read again>
T
l.10 ...ableeq{\eqone}{This & is & eqation 1}{eq1}
\\
?
My guess is that the &
symbols are not treated as intended but I may well be wrong there.
How can I define a command like \restatableeq
that allows me to re-use equations with the same content and number in a setting like in this example (and give it a label such that I can still use \ref
as usual in addition to that)?