# Alternative to nested aligned environments

I am interested in producing an effect similar to that produced by the following nested aligned environments.

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{align*}
A = ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 + 11 + 12 \\
&
\begin{aligned}
{} + 2 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 \\
&
\begin{aligned}
{} + 3 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 \\
& + 1 + 2 + 3 + 4))
\end{aligned}
\end{aligned} \\
&
\begin{aligned}
{} + 2 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8\\
& + 1 + 2 + 3 + 4 + 3 + 5 + 6 ))
\end{aligned}
\end{align*}
\end{document}


Is there a less syntax-intensive way to produce this type of effect?

• @hooy I think it has been corrected. May 21, 2017 at 15:28
• @user161825: I corrected the spacing around some of your alignments; the operator is binary, so preceded it with {}. Also, I removed all the unnecessary information that doesn't pertain to your question.
– Werner
May 21, 2017 at 15:35
• @Werner Thank you! Can I ask you where I can read about whether to put the double braces or not? May 21, 2017 at 15:40

With variable tab stops, nesting aligned is unavoidable. But you can have less {} and clearer input.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
A = ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 \\
& + 2 ( \begin{aligned}[t]
1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 \\
& + 3 ( \begin{aligned}[t]
1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 \\
& + 1 + 2 + 3 + 4))
\end{aligned}
\end{aligned} \\
& + 2 ( \begin{aligned}[t]
1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8\\
& + 1 + 2 + 3 + 4 + 3 + 5 + 6 ))
\end{aligned}
\end{align*}

\end{document}


Nested aligned is more elegant, IMO, but here is another option using the array construct. Arrays are naturally more tight, so one can add \renewcommand{\arraystretch}{1.2} to get lines a little spaced.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\noindent First with nested \verb|aligned|:
\begin{align*}
A = ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 + 11 + 12 \\
&
\begin{aligned}
{} + 2 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 \\
&
\begin{aligned}
{} + 3 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8 \\
& + 1 + 2 + 3 + 4))
\end{aligned}
\end{aligned} \\
&
\begin{aligned}
{} + 2 ( 1 & + 2 + 3 + 4 + 5 + 6 + 7 + 8\\
& + 1 + 2 + 3 + 4 + 3 + 5 + 6 ))
\end{aligned}
\end{align*}
%
And with \verb|array|:
%
\setlength{\arraycolsep}{0pt}
\begin{equation*}
\begin{array}{rlll}
A = ( 1 & \multicolumn{3}{l}{{}+ 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 + 11 + 12} \\
& {} + 2 ( 1 & \multicolumn{2}{l}{{}+ 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10}\\
&            & {} + 3 ( 1 & {}+ 2 + 3 + 4 + 5 + 6 + 7 + 8 \\
&            &            & {}+ 1 + 2 + 3 + 4))\\
& {} + 2 ( 1 & \multicolumn{2}{l}{{}+ 2 + 3 + 4 + 5 + 6 + 7 + 8}\\
&            & \multicolumn{2}{l}{{}+ 1 + 2 + 3 + 4 + 3 + 5 + 6 ))}\\
\end{array}
\end{equation*}

\end{document}