# Equations with operations next to each line

I basically want to type a derivation of a specific mathematical formula with the operations that have been done in each line, for e.g.:

  U = R * I      |:R
U/R = I


Handwritten it looks like this:

-
What would I do if my "final solution" is a mixture of multiple answers? – Simon D. Seim Jul 9 '14 at 13:10
Probably choose the one that was the most helpful in getting to your final solution. :) – Svend Tveskæg Jul 9 '14 at 15:11

Use the align environment (within amsmath package):

\begin{align*}
U          &=RI    &  &\div R\\
\frac{U}{R}&=I     &  &
\end{align*}


The first and third & align the sets of equations (say first and second column), while the second sign & separates the "columns" of equations

-
Same answer with better explanations ! You should add a * in \end{align} to make it perfect. – Tom-Tom Jul 3 '14 at 15:35
@V.Rossetto Thank you! :-P – Dox Jul 3 '14 at 17:52
You shouldn't use align (or align*) if you have more than one ampersand. In this case, you should use alignat (or alignat*) and specify the number of alignment points. – Svend Tveskæg Jul 7 '14 at 17:03
Why not? It does the job. And you do not have to add manual horizontal space – daleif Jul 7 '14 at 18:54
@SvendTveskæg. The align environments are designed to be used with more than two ampersands. – Tom-Tom Jul 8 '14 at 5:54

You can use the align* environment:

\begin{align*}
U&=RI & \div R\\
\frac{U}{R}&=I &
\end{align*}

-
It is better to use two &'s before the 'operation/comment', like in Dox's answer. – jmc Jul 3 '14 at 15:02
@jmc. Why ? This will align the comments on their left. – Tom-Tom Jul 3 '14 at 15:09
@V.Rosetto — Exactly. – jmc Jul 3 '14 at 15:11
@jmc. Somehow, it seems more agreeable to me to have the comments right-aligned. A matter of taste, anyway. Thanks. – Tom-Tom Jul 3 '14 at 15:16

Here is another way of doing it:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
&& U &= R \cdot I \qquad \vert\ :R \\
\ArrowBetweenLines
&& \frac{U}{R} &= I
\end{alignat*}
\vspace{4ex}
\begin{alignat*}{2}
&& U &= R \cdot I \\
\text{(Divide by $R$)}\Updownarrow \quad &&& \\
&& \frac{U}{R} &= I
\end{alignat*}

\end{document}


Of the two approaches, I would use the bottom one.

-