# Math indentation environment

I'd often like to set formulas like

Is there some other way than doing this by manually inserting whitespace (with \quad etc.), i.e., something like

\begin{align*}
f( & 1 + g( & 2 + \\
&        & 3), \\
& 4 + 5 + 6 + 7)
\end{align*}

So in the first line which contains an nth & symbol, its horizontal position should be remembered. When a subsequent line contains an nth & symbol, the text should continue at the remembered position.

Afaik align etc. can't do this because 2 + and 3 would be moved to the right because 4 + 5 + 6 + 7) occupies too much space.

-
I'm curious, can you say why you'd like to do that? – Hendrik Vogt Jun 18 '12 at 17:09
I occasionally have long (~3 lines) logical formulas with large terms. One example contains an if-then-else with conjunctions with a \max with a \sum with a large term. Thank you so much for all the answers! – chs Jun 19 '12 at 7:59
@HendrikVogt I know it's been a year since you've asked this question but let me still add this: the example might be too minimalistic to see the benefit but it's actually just the indentation scheme most used for programming languages so it makes sense to me to structure equations the same way. Too bad LaTeX has such a poor support for this as of know :/ – Christian Jun 16 '13 at 17:55

$\begin{array}{r@{}l@{}l} f( & 1 + g( & 2 + \\ & & 3), \\ & \multicolumn{2}{@{}l}{4 + 5 + 6 + 7)} \end{array}$