views:

27

answers:

1

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:

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!

+1  A: 

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.

Iain
I like your style. The gap seems hard to get rid of. Unless something that really removes the gap comes up, I'll check yours as the accepted answer.
progo
Thanks! Yeah, I'm not sure about the gap. Perhaps playing with tabular's settings in more detail would get you what you want. You may want to look at: http://www.andy-roberts.net/misc/latex/latextutorial4.html, a very helpful page on working with LaTex's tabular environment.
Iain