TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When presenting a lengthy mathematical derivation that draws upon previously introduced theorems or equations, it is good practice to write down the derivation line for line (e.g. using the align environment) and then adding the number of the theorem or equation used in a particular step at either the left or right margin of the line where it is applied.

Is there a package or a good, clean way to accomplish this? I feel that my current approach of using alignat{2} instead is a bit clumsy.

  & &   foo &= bar \\
  \text{Lemma \ref{lem:Bla} &\quad & foo &= boo
share|improve this question
up vote 3 down vote accepted

You can use the \tag macro in any of the amsmath display environments to put a label on a line of an equation, for example a theorem you want to refer to. If you also want a genuine line number, you have to do a bit of programming or else the \tag redefines the "number" that \ref will print to be whatever tag you chose (probably not what you want for a line number). Here's a rough attempt:

 \tag*{by Lemma \ref{#1} \quad  (\theequation)}%
  We have foo equal to bar.

  We have foo equal to boo.

 That is, we have
  \text{foo} &= \text{bar} \referto{lem:one}{line:one} \\
  \text{foo} &= \text{boo} \referto{lem:two}{line:two} \\
  \text{boo} &= \text{bar} \label{line:three}
 whence the theorem (see lines \ref{line:one}, \ref{line:two}, \ref{line:three}).


The only totally opaque piece is the \mylabel command. As it turns out, amsmath redefines \label to play with \tag, but we don't want this, so we just save the original version for our own use.

share|improve this answer
That would work. But what if I also want that equation to have number which I can use \ref to refer to later? – Lagerbaer May 7 '11 at 2:55
I've included an attempt at this, though it could be polished more. – Ryan Reich May 7 '11 at 3:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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