How can I write an aligned environment with multiple anchor types?
Is it something like this you're after? I used alignedat
to have full control on the columns spacing, and the optional [t]
for the placement of the opening parenthesis, the closing being added at the end of the last line:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
\begin{gather}
\begin{aligned}
&\text{lorem} + \text{ipsum} \\
= (&\begin{alignedat}[t]{3}
&\text{dolor} &&+\text{sit} &&+\text{amet} \\
&\text{consectetur} &&-\text{adipiscing} &&-\text{elit})
\end{alignedat} \\
= (&\begin{alignedat}[t]{2}
&\text{sed} &&-\text{do} \\
&\text{siusmod} &&+\text{tempor}).
\end{alignedat}
\end{aligned}
\end{gather}
\end{document}
Here is an array solution, and a tabular* solution including equation numbers.
Note that \extracolsep
does not apply before the first or after the last column.
\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\newcommand{\mytag}{\refstepcounter{equation}\llap{(\theequation)}}
\begin{document}
\begin{equation}
\begin{array}{rlll}
& \text{lorem} + \text{ipsum} \\
= (& \text{dolor} &+\text{sit} &+\text{amet} \\
& \text{consectetur} &-\text{adipiscing} &-\text{elit}) \\
= (& \text{sed} &-\text{do} \\
& \text{siusmod} &+\text{tempor}).
\end{array}
\end{equation}
\noindent\begin{tabular*}{\textwidth}{@{}l% left margin, leave empty
@{\extracolsep{\fill}}>{$\displaystyle}r<{$}
@{\extracolsep{0pt}\hspace{2\tabcolsep}}>{$\displaystyle}l<{$}
>{$\displaystyle}l<{$}
>{$\displaystyle}l<{$}
@{\extracolsep{\fill}}r@{}}
& & \text{lorem} + \text{ipsum} \\
&= (& \text{dolor} &+\text{sit} &+\text{amet} \\
& & \text{consectetur} &-\text{adipiscing} &-\text{elit}) &\mytag \\
&= (& \text{sed} &-\text{do} \\
& & \text{siusmod} &+\text{tempor}). &&\mytag
\end{tabular*}
\end{document}