我有以下等式:
\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}
这段代码的结果是 我想将等式的第二行向左移动,以便等式标签不使用另一行。
答案1
\hspace*{-15pt}
像&
这样添加:
\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.
答案2
删除最后一个\\
。我提出了另外四种变体,其中multlined
需要加载mathtools
而不是amsmath
;其中一种将整个方程放在一行上:
\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}
答案3
您可以通过 align-command 的位置来定义这一点&
。目前,您正在将产品的左侧与上方z
的行对齐。只需尝试这些位置即可。
两个注意事项:不要\\
在最后一行打字。如果在第一行对齐,z
,则逗号后的自动间距将被禁用。请,{}&z
改为这样做。
% 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}
离题:我建议把 = 写在第二行。参见https://tex.stackexchange.com/a/172110
答案4
这是 的工作multline
;我通过使用 来更改复杂的下标\substack
,以避免其过长。请注意,我更喜欢第一个未调整的版本。
\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}