# Move second line in an equation to the left with split

I have the following equation:

$$\begin{split} f_a(w_1,\ldots,w_m,&z_{w_1pa},\ldots,z_{w_mpa},a) = \\ &\prod_{j\in \{1,\ldots,m\} \mid z_{w_jpa} \neq \emptyset} \left( \left|z_{w_jpa} - a\right| + \left(-1\right)^{|z_{w_jpa} - a|} w_j\right)\\ \end{split}$$


The result of this code is I want to move the second line of the equation to the left so that the equation label does not use another line.

Add \hspace*{-15pt} after & like this:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{split} f_a(w_1,\ldots,w_m,&z_{w_1pa},\ldots,z_{w_mpa},a) = \\ &\hspace*{-15pt}\prod_{j\in \{1,\ldots,m\} \mid z_{w_jpa} \neq \emptyset} \left( \left|z_{w_jpa} - a\right| + \left(-1\right)^{|z_{w_jpa} - a|} w_j\right) \end{split}$$
\end{document}

\hspace* ensures that the space is given unlike other
\hspace, \hskip commands especially when given at the
beginning of the line.

• One last thing. It has to be ,{}&z Apr 30 '15 at 11:41

Delete the last \\. I propose four other variants, of which multlined requires loading mathtools instead of amsmath; one has the whole equation on one line:

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage[showframe]{geometry}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\begin{document}

\begin{multline}
f_a(w_1,\ldots,w_m,z_{w_1pa},\ldots,z_{w_mpa},a) =\\%
\prod  _{j \in \{1,\ldots,m\} ∣z_{w_jpa} \neq \emptyset} \bigl( \abs{z_{w_jpa} - a} + \left(-1\right)^{\abs{z_{w_jpa} - a}} w_j\bigr)
\end{multline}
\vskip 0.5cm

$$\begin{split} f_a(w_1,\ldots,w_m,{}&z_{w_1pa},\ldots,z_{w_mpa},a) = \\ &\prod _{j \in \{1,\ldots,m\} ∣z_{w_jpa} \neq \emptyset} \left( \abs{z_{w_jpa} - a} + \left(-1\right)^{\abs{z_{w_jpa} - a}} w_j\right) \end{split}$$
\vskip 0.5cm

$$\begin{multlined} f_a(w_1,\ldots,w_m, z_{w_1pa},\ldots,z_{w_mpa},a) = \\ \prod _{j \in \{1,\ldots,m\} ∣z_{w_jpa} \neq \emptyset} \left( \abs{z_{w_jpa} - a} + \left(-1\right)^{\abs{z_{w_jpa} - a}} w_j\right) \end{multlined}$$%
\vskip 0.5cm

\begin{aligned} \MoveEqLeft f_a(w_1,\ldots,w_m, z_{w_1pa},\ldots,z_{w_mpa},a) = \\ & \prod _{j \in \{1,\ldots,m\} ∣z_{w_jpa} \neq \emptyset} \left( \abs{z_{w_jpa} - a} + \left(-1\right)^{\abs{z_{w_jpa} - a}} w_j\right) \end{aligned}%
\vskip 0.5cm

$$f_a(w_1,\ldots,w_m,{}z_{w_1pa},\ldots,z_{w_mpa},a) = \\ \prod _{\mathclap{\substack{j \in \{1,\ldots,m\} \\ z_{w_jpa} \neq \emptyset}}}\!\left( \abs{z_{w_jpa} - a} + \left(-1\right)^{\abs{z_{w_jpa} - a}} w_j\right)$$
\end{document}


• Oops! Thanks for pointing it. I change that at once! Apr 30 '15 at 10:31
• your are welcome. with ,{}& you even get my vote :-) Apr 30 '15 at 10:35
• @LaRiFaRi: I even added a fifth solution:o) Apr 30 '15 at 11:22
• uh, like that one. And +1 it is. Apr 30 '15 at 11:40

You may define this by the placement of the align-command &. At the moment you are aligning the left side of your product to the z of the line above. Just play around with those placements.

Two remarks: Do not type \\ on your last line. If you align to the ,z in your first line, you will disable the automatic spacing after the comma. Please do ,{}&z instead.

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\setcounter{equation}{7}
% without any alignment.
$$\begin{split} f_a(w_1,\ldots,w_m,z_{w_{1\mathrm{pa}}},\ldots,z_{w_{m\mathrm{pa}}},a) = \\ \prod_{\mathclap{j\in \{1,\ldots,m\} \mid z_{w_{j\mathrm{pa}}} \neq \emptyset}} \bigl( |z_{w_{j\mathrm{pa}}} - a| + (-1)^{|z_{w_{j\mathrm{pa}}} - a|} w_j\bigr) \end{split}$$

% aligned left
$$\begin{split} &f_a(w_1,\ldots,w_m,z_{w_{1\mathrm{pa}}},\ldots,z_{w_{m\mathrm{pa}}},a) = \\ &\prod_{\mathrlap{j\in \{1,\ldots,m\} \mid z_{w_{j\mathrm{pa}}} \neq \emptyset}} \bigl( |z_{w_{j\mathrm{pa}}} - a| + (-1)^{|z_{w_{j\mathrm{pa}}} - a|} w_j\bigr) \end{split}$$

% aligned to the z as in your MWE
$$\begin{split} f_a(w_1,\ldots,w_m,{}&z_{w_{1\mathrm{pa}}},\ldots,z_{w_{m\mathrm{pa}}},a) = \\ &\prod_{\mathclap{j\in \{1,\ldots,m\} \mid z_{w_{j\mathrm{pa}}} \neq \emptyset}} \bigl( |z_{w_{j\mathrm{pa}}} - a| + (-1)^{|z_{w_{j\mathrm{pa}}} - a|} w_j\bigr) \end{split}$$
\end{document}


off-topic: I would recommend to write the = on the second line. See https://tex.stackexchange.com/a/172110

This is a job for multline; I changed the complicated subscript by using \substack that avoids making it too long. Note that I'd prefer the first unadjusted version.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

This is the default rendering
\begin{multline}
f_a(w_1,\ldots,w_m,z_{w_1pa},\ldots,z_{w_mpa},a) = \\
\prod_{\substack{j\in \{1,\ldots,m\} \\ z_{w_jpa} \neq \emptyset}}
\Bigl( \lvert z_{w_jpa} - a\rvert + (-1)^{|z_{w_jpa} - a|} w_j\Bigr)
\end{multline}
and this happens if you add some balanced spaces
\begin{multline}
\hspace{4em}
f_a(w_1,\ldots,w_m,z_{w_1pa},\ldots,z_{w_mpa},a) = \\
\prod_{\substack{j\in \{1,\ldots,m\} \\ z_{w_jpa} \neq \emptyset}}
\Bigl( \lvert z_{w_jpa} - a\rvert + (-1)^{|z_{w_jpa} - a|} w_j\Bigr)
\hspace{4em}
\end{multline}

\end{document}


• shouldn't the ='s be moved down to the second line? Apr 30 '15 at 10:53
• @daleif Personal preferences. Apr 30 '15 at 10:54