문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top