8

I found my self writing a paper. There I introduced an equation. I wanted to reference to the before introduced equation. My equation has a label. But as I think there is a need to recall the equation. I want to have the content of the equation repeated.

I already searched for a solution online and the following is kinda what popped up everywhere: (Maybe my search terms weren't that precise though...)

repeating an equation and getting the same equation number?

The thing here is that it relies on copying the content of the equation (that I could edit later on for didactic reasons w/o changing the copy as well).

What I want is something like the following:

\begin{equation}
    1+2=3
    \label{eq:easyformula}
\end{equation}

Some pages later…

Let's recall equation \ref{eq:easyformula} which was:
\displayLabeledSomething{eq:easyformula}

Of course in a case simple and made up like this it doesn't make a whole lot of sense to do so. Anyway its quite useful if equations get bigger and longer. And of course you don't have to search the document for the original formula and then copy and paste it... (which is error-prone and discouraged anyway).

I don't really want to use some sort of typing intensive macro for the purpose. A simple (maybe ready made command) like in the example would be optimal.

While typing this the prediction algorithm found the following:

How to repeat text without duplicating it?

which is indeed very similar to what I want but to be honest I don't understand that solution at all.

2

1 Answer 1

10

Perhaps something like this is what you want:

\documentclass{article}
\usepackage{amsmath}
\newcommand\labelAndRemember[2]
  {\expandafter\gdef\csname labeled:#1\endcsname{#2}%
   \label{#1}#2}
\newcommand\recallLabel[1]
   {\csname labeled:#1\endcsname\tag{\ref{#1}}}
\begin{document}
Deep insight:
\begin{equation}
  \labelAndRemember{eq:easyformula}
  {1+2=3}
\end{equation}
… several pages later …
\begin{equation*}
  \recallLabel{eq:easyformula}
\end{equation*}
\end{document}

Preview of this answer

5
  • gotta try this out freakin out if it works ...
    – der bender
    Nov 12, 2018 at 14:03
  • yes it works thank you the * in the second equation Environment appears to be not neccessary though
    – der bender
    Nov 12, 2018 at 14:08
  • it appears to be not working though if the commands are defined in a seperate file, that is then included in the preamble… for some non obvious reason
    – der bender
    Nov 12, 2018 at 14:32
  • related to my comment from nov12 14:32: it works also if placed in a different file but only if included in the main document with \input instead of \include
    – der bender
    Dec 11, 2018 at 14:42
  • Works well! I've had no trouble \recallLabeling across files.
    – wkschwartz
    Sep 3, 2021 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .