我有兴趣产生类似于以下嵌套对齐环境产生的效果。
\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}
有没有一种语法不太复杂的方法来产生这种效果?
答案1
使用可变制表位时,嵌套aligned
是不可避免的。但您可以减少{}
输入并使其更清晰。
\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}
答案2
在我看来,嵌套aligned
更优雅,但这是使用array
构造的另一种选择。数组自然更紧密,因此可以添加\renewcommand{\arraystretch}{1.2}
以使行稍微间隔开。
\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}