# Is it possible to re-insert a LaTeX equation by label?

Is it possible to re-insert an equation in LaTeX via referencing the original equation by label? I already know, it is possible to:

• reuse the original equation numbering via \tag{} as described here
• re-insert an equation by "boxing" the original one as said here

But isn't it possible to reuse the whole equation (i.e. its text and numbering) just using the label? Wouldn't it be natural to do so, instead of artificially creating additional labels by "boxing"? I'm feeling there must be a better way, or is my intuition wrong?

• No it would not be natural, as you can only reuse something, if it was saved before. Usually you don't need to reuse it, so by default the equation's content is not saved.
– bodo
Jul 18, 2012 at 8:09
• I disagree - the whole document is written as text file and hence persistent. It doesn't need saving, it's already saved. I still think it would be natural, or at least could be e.g. a label's attribute whether the whole equation can be reinserted later. Just a plain old academic thought.
– mmm
Jul 18, 2012 at 8:18
• Certainly the text file is persistent. But to access the particular piece of code making up your equation, a lot of parsing has to take place. So the only reasonable approach is saving the equation — either as the original character string,the tokenized input or the final expanded version — and later accessing that saved version.
– bodo
Jul 18, 2012 at 8:28
• Always right, huh? :)
– mmm
Jul 18, 2012 at 8:32
• @mmm: the persistency of the equation in the file only helps if you repeatedly re-read the file. LaTeX can't easily do that without disrupting the typesetting, so that persistency is moot. What LaTeX does is to save labels, etc. as macros in an auxiliary file which it reads into memory precisely once (at the beginning of the document). To save every labelled equation for re-use, you could modify the labelling macro so that in a displayed math environment it saves everything until the next newline or the end of the math with the equation number. If you're up for a challenge, try it yourself! Jul 18, 2012 at 10:24

Usually, almost everything is possible, but what you want does not exist yet (AFAIK). What you are asking for is a macro, which goes back to the label, copies the environment completely and expands it at another place, changing the \label into something like \tag in amsmath.

I'm quite convinced that the hacker fraction here could come up with a solution with less than 20 lines of code within half an hour.

But be warned: Why the amsmath package only offers the \tag-solution? Isn't it more usual to refer to an equation by citing its number than to reprint it completely?

• Correction: Everything is possible. (La)TeX is turing-complete. 😜
– rugk
Jun 29, 2019 at 17:35
• @rugk, seriously ? can you explain a bit more ? ok you mean you can implement a Turing machine with LaTeX, hence you could perform any task ? Oct 19, 2021 at 13:54
• @RémyHosseinkhanBoucher well the turing-complete fact is a thing I'd call popular knowledge. What this basically means is that, according to the Church–Turing thesis, any computable algorithm or so is implementable, because all "basic building blocks" are there. (a little simplified). Just information science things… 😜
– rugk
Oct 29, 2021 at 20:42

I know this question is old but I thought I'd give my input. It seems like the easiest solution would be to save the equation in a separate file and just \input{} the equation whenever it is needed, using whatever desired means to attach the right equation number to it. Of course this could get messy if you have a lot of equations like this. Maybe then you could save them all in a subdirectory. Not elegant but it should work.

• IMHO splitting your LaTeX document in small files and using a folder equations/lorme-ipsum-number.tex is actually a clean and proper solution and no hack. Also, it fullfills this wish very easily without much "LaTeX hacking" (ref. "hacker fraction", @Keks Dose)
– rugk
Aug 26, 2020 at 17:49