# Equation: align several equations that are themselves split at several points

I'm sorry if this thread looks similar to lot's of other threads, but I was not able to find a nice solution to my problem. Basically, I would like to align some equations, but I also would like these equations to be split into several lines, and indented using different points like that (see for example the equation 4 that has two break points):

The main problem is that with alignat, the & is not a simple mark to say "align this point with this point", but & really delimits columns. So if one line before or after is too long, it makes all the other elements in the same column longer.

For now, I solve my problem by putting \nonumber (so it means that the equation numbers like (2) are not centered in the equation when the number of lines is even) and \hspace{<find the good space in 5 tries>} everywhere, but it's really not practical/elegant.

Do you have a better solution? Here is a MWE, with at the beginning my "ideal syntax":

\documentclass{article}
\usepackage{mathtools}

\begin{document}
My ideal syntax:
% \begin{align}
%   2\times(1+\dots+10) &= 2 \times (1+2+3+4+5+6+7+8+9+10)\\
%   &=
%     \begin{split}
%       2 \times (&1+2+3+4\\
%                 &+5+6+7+8+9+10)\\
%     \end{split}
%   &=
%     \begin{split}
%       (1+1) \times (&3+7\\
%                     &+11+7+8+19)
%     \end{split}
%   &=
%     \begin{split}
%       (1+1) \times (&1+2+&(3
%                     &    &+4)\\
%                     &+ 11+7+8+19)
%     \end{split}
% \end{align}

My more or less ideal result:

\begin{align}
2\times(1+\dots+10) &= 2 \times (1+2+3+4+5+6+7+8+9+10)\\
&= 2 \times (1+2+3+4\\
&\hspace{10mm} +5+6+7+8+9+10)\nonumber\\
&= (1+1) \times (3+7\\
&\hspace{20mm}+ 11+7+8+19)\nonumber\\
&= (1+1) \times (1+2+(3\nonumber\\
&\hspace{33mm}+ 4)\\
&\hspace{20mm}+ 11+7+8+19)\nonumber
\end{align}
\end{document}


-- EDIT --

The proposed solution is great, except if I use a macro that puts the brackets for me. For example, consider the following image. I'd expect the bracket at the right of the first line to be on the second line. And if I add a newline, then it goes alone on a third line which is not what I expect. And the same problem is true if I add stuff after the \pr. Is it possible to make this code work without inserting the alignedat inside the macro? (I like to have environment because it makes the indentation automatic, and I can't find how to produce an environment command for pr...

\documentclass{article}
\usepackage{mathtools}

\usepackage{etoolbox}
\newcommand*{\pr}[2][]{\Pr_{\substack{#1}}[\,#2\,]}
\begin{document}
\begin{align}
&\pr[a \leftarrow \{0,1\}]{
\begin{alignedat}[t]{2}
&\forall x\\
& \pr[b \leftarrow \{0,1\}]{b = a} \geq \delta
\end{alignedat}}+\alpha\\
&\geq \eta
\end{align}
\end{document}


Thanks!

You could nest alignedat environments.

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{alignat}{2}
2\times(1+\dots+10) &= 2 \times (1+2+3+4+5+6+7+8+9+10)\\
&=
\begin{alignedat}[t]{2}
2 \times (&1+2+3+4\\
&+5+6+7+8+9+10)
\end{alignedat}\\
&=
\begin{alignedat}[t]{2}
(1+1) \times (&3+7\\
&+11+7+8+19)
\end{alignedat}\\
&=
\begin{alignedat}[t]{2}
(1+1) \times (&1+2+
\begin{alignedat}[t]{2}
&(3\\
&+4)
\end{alignedat}\\
&+ 11+7+8+19)
\end{alignedat}
\end{alignat}
\end{document}


• Thanks a lot for this solution. However, I realized a small issue when the brackets are set by some macros (see my edit). Is it possible to solve this small issue? – tobiasBora Mar 29 at 21:11
• I'm not sure how to solve that... I think I would just not use that macro, or define another one that would not put the brackets on both sides. Sorry :/ – Vincent Mar 30 at 21:38
• Ok thanks anyway! I'll just add one more optional argument to add stuff after, even if it's a bit dirty. – tobiasBora Mar 31 at 18:09