量词对齐

量词对齐
\begin{document}
\begin{equation}
\begin{split}
    \sum_{s \in S_i} x_s &= 1 \quad \forall S_i \in P \\
    x_s &\leq \sum_{(s,t) \in R: t \in S_j} x_t \quad 
    \forall S_i \in P, \ \forall s \in S_i, \ \forall S_j \in P \ \textnormal{with} \ i < j \\
x_s &\in \{0,1\} \quad \forall s \in S.
\end{split}
\end{equation}
\end{document}

我怎样才能使量词也像 =/<= 那样对齐?

答案1

您可以使用alignedat

\documentclass{article}
\usepackage{amsmath}
\begin{document}

This is a possible solution
\begin{equation}
\begin{alignedat}{2}
\sum_{s \in S_i} x_s &= 1 &\quad& \forall S_i \in P \\
x_s &\leq \sum_{\substack{(s,t) \in R\\ t \in S_j}} x_t &\quad&
    \forall S_i \in P, \ \forall s \in S_i, \ \forall S_j \in P \ \textnormal{with} \ i < j \\
x_s &\in \{0,1\} &\quad& \forall s \in S.
\end{alignedat}
\end{equation}
but, in my opinion, the following is better
\begin{equation}
\begin{alignedat}{2}
&\!\sum_{s \in S_i} x_s = 1 &\quad& \forall S_i \in P \\
&x_s \leq \sum_{\substack{(s,t) \in R\\ t \in S_j}} x_t &\quad&
    \forall S_i \in P, \ \forall s \in S_i, \ \forall S_j \in P \ \textnormal{with} \ i < j \\
&x_s \in \{0,1\} &\quad& \forall s \in S.
\end{alignedat}
\end{equation}

\end{document}

在此处输入图片描述

答案2

这是一个使用aligned环境而不是split环境的解决方案,并使用\mathclap第二个参数\sum

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\begin{aligned}
\sum_{s \in S_i} x_s &= 1 
   &&\forall S_i \in P \\
x_s &\leq \sum_{\mathclap{(s,t) \in R: t \in S_j}} x_t  
    && \forall S_i \in P, \ \forall s \in S_i, \ \forall S_j \in P \textnormal{ with } i < j \\[1ex]
x_s &\in \{0,1\} && \forall s \in S.
\end{aligned}
\end{equation}
\end{document}

相关内容