# How to put arrows pointing to equalities to explain each step

What´s the best way to explain every equality? With arrows like in

Anything similar to this

-
– Jubobs Jun 3 '13 at 10:15
+1 for adding information about the question using the SO page of the question itself! – Bakuriu Jun 3 '13 at 16:25

I can suggest three possibilities.

\documentclass{article}
\usepackage{amsmath}

% for the first solution
\usepackage{mathtools}
\newcommand{\equalexpl}[1]{%
\underset{\substack{\uparrow\\\mathrlap{\text{\hspace{-1em}#1}}}}{=}}

\begin{document}

\begin{align*}
f(ax+by)
&\equalexpl{because $f(u+v)=f(u)+f(v)$}
f(ax) + f(by) \\
&\equalexpl{because $f(cu)=cf(u)$}
af(x) + bf(y)\\
\end{align*}

\begin{alignat*}{2}
f(ax+by)
&= f(ax) + f(by)\qquad &&\text{because $f(u+v)=f(u)+f(v)$} \\
&= af(x) + bf(y)\qquad &&\text{because $f(cu)=cf(u)$}
\end{alignat*}

\begin{align*}
&f(ax+by)\overset{(1)}{=} f(ax) + f(by) \overset{(2)}{=} af(x) + bf(y)\2ex] &\text{(1) because f(u+v)=f(u)+f(v)} \\ &\text{(2) because f(cu)=cf(u)} \end{align*} \end{document}  - egreg Thank you. Good solution I like your propose – Mika Ike Jun 3 '13 at 13:08 Here's a solution using TikZ: \documentclass{article} \usepackage{tikz} \newcounter{mybox} \newcommand\tikzmark[1]{% \tikz[remember picture,overlay] \node[inner xsep=0pt] (#1) {}; } \newcommand\ColorBox[2][]{% \stepcounter{mybox}% \node[draw=red!70!black,fill=red!20,align=left,#1] (box\themybox) {#2}; } \begin{document} \[ a(b + c) \tikzmark{a}= ab+ac \tikzmark{b}= ba+ca.
\begin{tikzpicture}[remember picture,overlay]
\ColorBox[xshift=3cm]{by distributivity}
\draw[red!70!black,->] (box1) -| ([xshift=7.5pt]a.south west);
\ColorBox[xshift=10cm,fill=blue!30,draw=blue]{by commutativity}
\draw[blue,->] (box2) -| ([xshift=7.5pt]b.south west);
\end{tikzpicture}

\end{document}


\ColorBox has one optional argument to control options for the \node used to draw the box, and a mandatory argument for the explanatory text. The associated node is automatically named box<number>. Using \tikzmark you mark any element that will be the end of the arrow and then you can draw the arrow with a standard \draw command.

-
\usetikzlibrary{tikzmark} – Loop Space Jun 3 '13 at 16:46

If I understand your referenced image properly

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\begin{array}{lll} f(ax+by) &= f(ax) + f(by) &= a f(x) + b f(y)\\ &\uparrow &\uparrow \\ & \textrm{because } f(x+\mu) = f(x) + f(\mu) &\textrm{because }f(z\lambda) = z f(\lambda) \\ \end{array}$

\end{document}


-
Steven B. Segletes I like. I adjust to my TEX files. Thank you – Mika Ike Jun 3 '13 at 13:11