Math & Science"Re-using" Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
cpaitor
Posts: 1
Joined: Tue Jul 26, 2011 3:48 pm

"Re-using" Equations

Post by cpaitor »

Hi

Is there an easy way to "re-use" an entire equation environment that is defined elsewhere in the tex source?

To clarify what I mean. Suppose that I have already defined coded up an equation as

Code: Select all

\begin{equation}
 bla bla bla
 \label{eq}
\end{equation}
and later (or at an earlier point) want to show the equation again (for one thing the equation might be derived in a supplementary appendix) using the same equation numbering. Now I could of course simply copy and paste the code snippet, but then I would get two reference numbers for the same equation which is what I'm trying to avoid. Hence any suggestions would be appreciated.

For now I have solved this by defining a new enviroment

Code: Select all

\newcounter{neqn}
\newenvironment{numeqn}[1][?]
{\setcounter{neqn}{\value{equation}}\renewcommand{\theequation}{#1}\begin{equation}}
{\end{equation}\setcounter{equation}{\value{neqn}}}
which allows me to set the same equation number as

Code: Select all

\begin{numeqn}[\ref{eq}]
 bla bla bla
\end{numeqn}
however I still have to copy and paste the piece of tex source that sets the equation itself, thus if I later realize that the formula is erroneous, there is a good chance that I only remember to edit the formula in one of the places where it occurs.

regards Paitor

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply