# Can I (sub-)align some but not all of the lines in a multi-line equation?

I have a multiline equation and want some of the lines to be aligned at an additional symbol. Here is an example, where all lines are aligned at the equal sign, but lines 2 and 3 should additionally be aligned at the multiplication sign:

y = a + b + c +
(5 - 3)   x (10 - 5) +
(10 - 30) x (10 - 1) +
e + f + g + h


Currently I use

\begin{align}
\begin{split}\label{mylabel}
y ={}&a + b + c +
&(5 - 3) \times (10 - 5) +
&(10 - 30) \times (10 - 1) +
&e + f + g + h
\end{split}
\end{align}


to align the equation after the equal sign.

Is there a way to add the alignment at \times for rows 2 and 3 without forcing the entire first and last lines "on one side of the alignment"?

• There's a way, but you'll have a white space in the second line (or you'll lose the first alignment). Apr 29, 2016 at 10:54

You can use aligned or alignedat:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{split}\label{mylabel}
y &= a + b + c\\
\!\begin{alignedat}[t]{2}
&+ (5 - 3) &&\times (10 - 5) \\
&+ (10 - 30) &&\times (10 - 1) \\
\end{alignedat}\\
&\quad + e + f + g + h
\end{split}
\end{align}

\end{document}


alignedat provides a number of pairs of columns, the first aligned to the right, the next to left, etc. There is a standard small space automatically inserted before the environment, which I cancel with a negative thin space \!.

I have kept your outer aligned presuming you have a good reason for that, but equation looks to be more appropriate in this concrete case. Also I have moved the binary operators in relation to the line breaks to give a more standard appearance. If you really want them at the ends of lines then you will have to write +{}\\ each time to get correct spacing:

\begin{align}
\begin{split}\label{mylabel}
y ={}& a + b + c +{}\\
&
\!\begin{alignedat}[t]{2}
&(5 - 3) &&\times (10 - 5) +{}\\
&(10 - 30) &&\times (10 - 1) +{}\\
\end{alignedat}\\
&e + f + g + h
\end{split}
\end{align}


but this is not the standard way to split such equations.

• Thanks, that is perfect! And +1 for giving it "a more standard appearance". I was actually wondering about what a good standard for the placement of the operators was in multi-line equations. Apr 29, 2016 at 11:14