13

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?

6
  • 1
    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 '12 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 '12 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 '12 at 8:28
  • Always right, huh? :) – mmm Jul 18 '12 at 8:32
  • 1
    @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! – Niel de Beaudrap Jul 18 '12 at 10:24
12

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?

1
  • Correction: Everything is possible. (La)TeX is turing-complete. 😜 – rugk Jun 29 '19 at 17:35
4

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.

1
  • 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 '20 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.