Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

\begin{alignat}{2}
  & &   foo &= bar \\
  \text{Lemma \ref{lem:Bla} &\quad & foo &= boo
\end{alignat}
share|improve this question
add comment

1 Answer

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:

\documentclass{article}
\usepackage{amsmath}
\newtheorem{lem}{Lemma}
\let\mylabel=\label
\newcommand*{\referto}[2]{
 \refstepcounter{equation}%
 \mylabel{#2}
 \tag*{by Lemma \ref{#1} \quad  (\theequation)}%
}
\begin{document}
 \begin{lem}
  \label{lem:one}
  We have foo equal to bar.
 \end{lem}

 \begin{lem}
  \label{lem:two}
  We have foo equal to boo.
 \end{lem}

 That is, we have
 \begin{align}
  \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}
 \end{align}
 whence the theorem (see lines \ref{line:one}, \ref{line:two}, \ref{line:three}).

\end{document}

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
add comment

Your Answer

 
discard

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.