5

I have the following equation:

\begin{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}
\end{equation}

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

0
2

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

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
   \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{equation}
\end{document}

 \hspace* ensures that the space is given unlike other 
\hspace, \hskip commands especially when given at the 
beginning of the line.
1
  • One last thing. It has to be ,{}&z
    – LaRiFaRi
    Apr 30 '15 at 11:41
4

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{equation}
  \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}
\end{equation}
\vskip 0.5cm

\begin{equation}
  \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}
\end{equation}%
\vskip 0.5cm

\begin{equation}
  \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}
\end{equation}%
\vskip 0.5cm

\begin{equation}
  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{equation}
\end{document}

enter image description here

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

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{equation}
    \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{equation}

% aligned left
\begin{equation}
    \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}
\end{equation}

% aligned to the z as in your MWE
\begin{equation}
    \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{equation}
\end{document}

enter image description here


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

1

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.