Question

I'm writing a description of how recursive functions are applied within lists using the align environment from amsmath in LaTeX. Here's the code:

\begin{align*}
  & \reduce (+, 0,                  & [1, 2, 3, 4]) \\
= & \reduce (+, 0 + 1,              & [2, 3, 4]) \\
= & \reduce (+, 0 + 1 + 2,          & [3, 4]) \\
= & \reduce (+, 0 + 1 + 2 + 3,      & [4]) \\
= & \reduce (+, 0 + 1 + 2 + 3 + 4,  & []) \\
= & 0 + 1 + 2 + 3 + 4\\
= & 10
\end{align*}

or my try out to enhance the readability. Inserted \quads there:

\begin{align*}
 & \reduce (+,\quad 0,                   & [1, 2, 3, 4]) \\
=& \reduce (+,\quad 0 + 1,               & [2, 3, 4]) \\
=& \reduce (+,\quad 0 + 1 + 2,           & [3, 4]) \\
=& \reduce (+,\quad 0 + 1 + 2 + 3,       & [4]) \\
=& \reduce (+,\quad 0 + 1 + 2 + 3 + 4,   & []) \\
=& 0 + 1 + 2 + 3 + 4\\
=& 10
\end{align*}

It just doesn't look nice. Here's a quick picture of the latter:

http://havu.viuhka.fi/kuvat/alignenv.png

It is almost both readable and aesthetical, but not quite.

How to make the gap smaller? And any other tips you may have are appreciated!

Was it helpful?

Solution

How about using a tabular environment instead of align, with which you can more easily control alignment of the columns? I personally liked the results of:

\begin{tabular}{ r l c }
 & reduce(+,\;\, 0,                   & [1, 2, 3, 4]) \\
=& reduce(+,\;\, 0 + 1,               & [2, 3, 4]) \\
=& reduce(+,\;\, 0 + 1 + 2,           & [3, 4]) \\
=& reduce(+,\;\, 0 + 1 + 2 + 3,       & [4]) \\
=& reduce(+,\;\, 0 + 1 + 2 + 3 + 4,   & []) \\
=& 0 + 1 + 2 + 3 + 4\\
=& 10
\end{tabular}

Causes the set on the right to form (visually speaking) an upside down triangle shape. I also replaced \quad with \;\, \quad seemed like too much, and \; not enough... space there.

I briefly considered doing the same to the sums in their own column, but decided that the sums 'growing to the right' was visually more effective.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top