# Efficient way to indicate steps in a derivation

Imagine you're writing up a long derivation, and sometimes, the step to go from one equality to the next is nonobvious (for example, maybe it requires application of a theorem). In such cases, you should probably point-out to the reader whatever it is that justifies the equality.

There are at least two obvious ways of doing this, but of which I find suboptimal. The first is just do the entire derivation (with, e.g., \begin{align}\begin{split}\end{split}\end{align}), and then indicate at the end what facts you used and where (for example, you might say something like ". . . where we used Theorem 5.6 to go from the first line to the second, we used Proposition 4.3 to go from the second to the third, . . . "). As a reader, I find this a little annoying having to constantly flip back and forth between the derivation and what follows it.

The other possibility is to do the derivation more-or-less one step at a time so that there is less "flipping back and forth". This means, however, that the length of the derivation will increase significantly (in terms of the number of lines it takes), and to me, makes it feel a bit disjointed.

What I'm interested in is an efficient way to indicate what is being used at each step in the derivation itself. This would completely remove the "flipping back and forth" without significantly increasing the length of the derivation and not breaking it a part at all.

Do you guys have any suggestions for this?

• Something like tkz-linknodes? Take a look at the examples in the manual to see what it does. Mar 3, 2014 at 22:53
• I think that very much depends on the purpose of the paper. If it targets people with enough background to basically understand the equation itself, it would be enough to add in front or at the back "using eq. XX". The tkz-linknotes is very good if the target audience is like a highschool or undergrad class. If an equation gets too complex, I would always try to break it apart stating what is to be done before the actual result. Mar 4, 2014 at 5:28
• Maybe an example of what you mean could help in form ideas. Mar 4, 2014 at 7:53

I’m not quite sure what you’re looking for, but here’s something I was using today for a problem sheet that I might use again.

I use the \tag* command (like \tag in an equation environment, but the argument isn’t automatically wrapped in parentheses) to put an annotation at the side of equation. I then make the text smaller and dim the colour slightly, so it doesn't distract too much from the text.

Here's the command I used:

\newcommand*{\annot}[1]{\tag*{\footnotesize{\textcolor{black!50}{#1}}}}


and here's a sample of it from today's work:

The calculations at the side aren't particularly complicated, and I only put them there to show I actually know what's going on (and didn't just crib the answer from somewhere else). That might be what you're looking for.

The text in the final line is particularly long; any longer and I might consider breaking it out into a separate line. The \tag* environment does an acceptable job of handling this medium lines, but breaks badly for long ones. Here’s what that looks like:

For completeness, here's the associated MWE:

\documentclass{article}

\usepackage{amsmath}

\newcommand*{\annot}[1]{\tag*{\footnotesize{\textcolor{black!50}{#1}}}}

\begin{document}

Working from the generators, we have:
\begin{align*}
\idp \idq_1
&= (2, 1+\sqrt{-5}\,)\,(7, 3 + \sqrt{-5}\,) \\
&= (14, 6 + 2\sqrt{-5}\,, 7 + 7 \sqrt{-5}\,, -2 + 4 \sqrt{-5}\,) \\
&= (6 + 2\sqrt{-5}\,, 7 + 7 \sqrt{-5}\,, -2 + 4 \sqrt{-5}\,)
\annot{$14 = 2\,(6 + 2\sqrt{-5}\,) - (-2 + 4\sqrt{-5}\,)$} \\
&= (3 + \sqrt{-5}\,, 6 + 2 \sqrt{-5}\,, 7 + 7 \sqrt{-5}\,)
\annot{$3 + \sqrt{-5} = (7 + 7\sqrt{-5}\,) - (6 + 2\sqrt{-5}\,) - (-2 + 4 \sqrt{-5}\,)$} \\
&= (3 + \sqrt{-5}\,)
\annot{$6 + 2 \sqrt{-5} = 2\,(3 + \sqrt{-5}\,)$ and $7 + 7 \sqrt{-5} = (4 + \sqrt{-5}\,)\,(3 + \sqrt{-5})$}
\end{align*}
and we note that $4 + \sqrt{-5}\, \in \Ok$.

\end{document}

• This is good. I rather like this. May use it sometime. Thanks! Mar 4, 2014 at 22:12
• @alexwlchan I must say the this font is one the most readable I have ever seen. Which one is this? Jan 16, 2017 at 5:22
• @Dilawar Based on the date, I’d guess Lyon, but this is based on an old document template so I can’t be sure. Jan 16, 2017 at 7:19
• Copy-paste the MWE to a blank sheet raised the following error: "Undefined control sequence \end{align*}" for me (might be for others as well). Sep 6, 2017 at 14:46

Would something like that be convenient? I use flalign* to have an equations alignment in the center of the line and comments on the right side, ragged left thanks to the \llap command. If the equation on a line would overlap with the comment/justification, it is enough to write the comment on a supplementary line:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{mathtools}

\begin{document}

We have:
\begin{flalign*}
&  & A &  = B  &  & \llap{according to theorem .5.6}
\shortintertext{so that}
&  & C  & =  D   +  E + F \\
&  &  &  &   & \llap{(taking into account proposition 2.31)}
\end{flalign*}

\end{document}


I decided that the best way for me to solve this problem would be to use footnotes at the equality signs to indicate what is being used. Ordinarily, the footnote mark might be confused with an exponent, but for this purpose, the footnote will be on an equality sign (or something similar), and so there will be no confusion.

It turns out though, that doing this is not so straightforward, for two reasons: (1) You cannot by default make use of footnotes in, e.g., \begin{split}\end{split}; (2) The way to get around (1) involves nesting three environments along and, although not strictly necessary, \newenvrionment doesn't seem to be cable of creating a 'shorthand' environment for this.

All in all, I managed to piece together a solution that satisfies me using other answers I found on this site: Footnote in align environment, Making a new environment combining equation and split.

Here is a MWE of my solution applied to an actual derivation that motivated my original question.

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{environ}
\usepackage{slashed}

\NewEnviron{derivation}
{%
\\
\begin{minipage}{\linewidth}$$\begin{split} \BODY \end{split}$$\end{minipage}
}

\makeatletter
\newcommand{\mfootnote}[1]{%
\ifmeasuring@
\chardef\@tempfn=\value{footnote}%
\! \footnotemark
\setcounter{footnote}{\@tempfn}%
\else
\iffirstchoice@
\! \footnote{#1}%
\fi
\fi}
\makeatother

\begin{document}

This is a derivation.
\begin{derivation}
\delta S_2 & =-\int \mathrm{d}\, ^4x\, \left[ \delta \bar{\chi}\slashed{\partial}P_L\chi +\bar{\chi}\slashed{\partial}\delta (P_L\chi )\right] \\
& =\mfootnote{Commuting $P_L$ past the gamma matrix hidden in $\slashed{\partial}$ turns it into $P_R$.}-\int \mathrm{d}\, ^4x\, \left[ \delta (\overline{P_R\chi})\slashed{\partial}\chi +\frac{1}{\sqrt{2}}\bar{\chi}\slashed{\partial}P_L(\slashed{\partial}Z-\bar{W}')\epsilon \right] \\
& =-\frac{1}{\sqrt{2}}\int \mathrm{d}\, ^4x\, \left[ \overline{P_R(\slashed{\partial}\bar{Z}-W')\epsilon} \slashed{\partial}\chi+\bar{\chi}\slashed{\partial}P_L(\slashed{\partial}Z-\bar{W}')\epsilon \right] \\
& =\mfootnote{Here, we do a Majorana flip.  The term $\slashed{\partial}\bar{Z}$ has a single gamma matrix, and as $t_1=-1$ in $D=4$, we get a minus sign in this term.}-\frac{1}{\sqrt{2}}\int \mathrm{d}\, ^4x\, \left[ \bar{\epsilon}(-\slashed{\partial}\bar{Z}-W')P_R\slashed{\partial}\chi +\bar{\chi}\slashed{\partial}P_L(\slashed{\partial}Z-\bar{W}')\epsilon \right] \\
& =-\frac{1}{\sqrt{2}}\int \mathrm{d}\, ^4x\, \left[ -\bar{\epsilon}\slashed{\partial}\bar{Z}P_R\slashed{\partial}\chi -\bar{\epsilon}W'P_R\slashed{\partial}\chi +\bar{\chi}\slashed{\partial}P_L\slashed{\partial}Z\epsilon -\bar{\chi}\slashed{\partial}P_L\bar{W}'\epsilon \right] \\
& =\mfootnote{Here, we use the fact that $\slashed{\partial}\slashed{\partial}=\square$.  We also integrate by parts in the first term.  In the last term, we first commute $P_L$ past $\slashed{\partial}$ and then do a Majorana flip.}-\frac{1}{\sqrt{2}}\int \mathrm{d}\, ^4x\left[ \bar{\epsilon}(\square \bar{Z})P_L\chi -\bar{\epsilon}W'P_R\slashed{\partial}\chi +\bar{\chi}P_R\square Z\epsilon +\bar{\epsilon}(\slashed{\partial}\bar{W}')P_R\chi \right] \\
& =-\frac{\bar{\epsilon}}{\sqrt{2}}\int \mathrm{d}\, ^4x\, \left[ (\square \bar{Z})P_L\chi -W'\slashed{\partial}(P_L\chi )+(\square Z)P_R\chi +(\slashed{\partial}\bar{W}')P_R\chi \right] .
\end{derivation}

\end{document}