Math indentation environment
You can also do this with either:
- the
alignat
environment along with\matrlap{}
, or - with the
align
and use a\hphantom{}
to obtain:
1. Using \alignat
and \mathrlap
:
The alignat
provides multiple rl
align pairs. Since your second alignment is intended to be l
aligned, you use a double &&
. The first &
skips over the r
aligned column of the rl
align pair.
\mathrlap
and related macros are discussed in detail in this TuGboat paper.
Code:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{alignat*}{3}
f( & 1 + g( && 2 + \\
& && 3), \\
& \mathrlap{4 + 5 + 6 + 7)}
\end{alignat*}
\end{document}
2. Using \align
and \hphantom
:
You could also just use a \hphantom{}
to insert the exact horizontal spacing as is required by its parameter.
Code:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
f( & 1 + g( 2 + \\
& \hphantom{1 + g(} 3), \\
& 4 + 5 + 6 + 7)
\end{align*}
\end{document}
Yes, it's possible. Use an array
for stacking, and drop the intercolumn space, as needed using @{}
:
\documentclass{article}
\begin{document}
\[
\begin{array}{r@{}l@{}l}
f( & 1 + g( & 2 + \\
& & 3), \\
& \multicolumn{2}{@{}l}{4 + 5 + 6 + 7)}
\end{array}
\]
\end{document}
If you wish for a more breathable presentation, use \\[\jot]
instead of just \\
.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
\begin{array}{ r @{} l @{\mkern\thinmuskip} r }
f( & 1 + g( & 2 + \\
& & 3), \\
& \mathrlap{4 + 5 + 6 + 7)}
\end{array}
\]
\end{document}