对齐多个多行方程

对齐多个多行方程

我正在努力尝试对齐一组长度差异很大的方程式。所有方程式都应与公式和变量声明之间的逗号对齐。

尽管使用了,公式 3 仍然太长。如果我在和split之间再换行,就会出现错误\left(\right)"Extra }, or forgotten right"

拆分完成后,我想将这种多行公式的第一行左对齐,接下来的几行左对齐并在前面略微跳过,最后一行右对齐到逗号。有可能这样做吗?或者还有其他建议,可以在一个环境中以漂亮的方式一起呈现许多这样的长公式吗?

我找到了将一个长公式排列在多行中或将多个公式围绕逗号或其他内容排列在一起或将一个公式左对齐(如我所述)(mathtools' \MoveEqLeft)的解决方案,但我不知道如何同时完成所有这些操作。

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
    \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & ,     i \in \mathcal{I}_{21}
    \label{eq_1} \\
%
    \begin{split}
        \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    &   \\
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    & ,  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{split} 
    \label{eq_2} \\
%
    \begin{split}   
        \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        & \\
        \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
        & , i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \end{split}
    \label{eq_3} \\
%
    H_{21} = H_{12} 
    &       
    \label{eq_4}
\end{align}
\end{document}

补充:
到目前为止,我使用的是旧的 eqnarray 环境。使用它,它看起来几乎应该是这样的:

\documentclass{scrreprt}
\begin{document}
\begin{eqnarray}
\sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
\leq h_i 
\leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
& , {} &    i \in \mathcal{I}_{21}
\label{eq:sf_height_fits_levelheight_i21}\\
%
\left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
\times \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \qquad \qquad \quad
&    &      \nonumber \\
\qquad \times \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon |\right)
\geq 0
%
& ,  &      i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} \qquad \quad
\label{eq:sf_I22_not_in_new_I21} \\
H_{21} = H_{12}                             
&   &       
\label{eq:sf_def_H21}
\end{eqnarray}
\end{document}

唯一的问题:公式 3 太宽,公式数字超出了文本区域(并且 eqnarray 环境不是第一选择)。

答案1

这是一个aligned在环境中使用环境的解决方案align。它加载\mathtools包(及其\smashoperator宏)以压缩求和符号周围的空间。第三个等式增加了一个换行符,现在跨越了三行。

enter image description here

\documentclass{scrreprt}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs\lvert\rvert
\begin{document}
\setcounter{chapter}{1} % just for this example

\begin{align}
&\smashoperator[r]{\sum_{k=K_1+1}^{K_{21}-1}} 
   s_{ik} \tilde{h}_{k+1} 
   \leq h_i \leq 
   \smashoperator{\sum_{k=K_1+1}^{K_{21}}} 
   s_{ik} \tilde{h}_k + 
   \smashoperator{\sum_{k=K_1+1}^{K_{21}-1}} 
   \bar{s}_{ik} \tilde{h}_{k+1},
   \quad i\in\mathcal{I}_{21} \label{eq_1} \\[2ex]
%
&\smashoperator[r]{\sum_{l=K_{21}+1}^{K_{22}}}
  \begin{aligned}[t]
  &\alpha_{lk} (s_{il} + \bar{s}_{il}) (1+\varepsilon) 
    + w_i + 
   \smashoperator{\sum_{j=I_1+1}^{I_2}} 
   \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j\\
  &\geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    ,\quad  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
  \end{aligned} 
    \label{eq_2} \\[2ex]
%
&\begin{aligned}   
  &\biggl( 1- \smashoperator{\sum_{j=I_1+1}^{I_2}}
          \alpha_{ji}t_{jk}\biggr)
   \times \biggl( w_i - \frac{1}{m+2} - \varepsilon -
   \abs[\Big]{w_i - \frac{1}{m+2} - \varepsilon}
   \biggr) \times \dotsb \\
  &\quad\dotsb\times\biggl( h_i + 
   \smashoperator{\sum_{l=K_1+1}^{K_2}} 
   \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
   \abs[\Big]{ h_i + 
   \smashoperator{\sum_{l=K_1+1}^{K_2}} 
   \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon } 
   \biggr)
= 0,\\
  &\qquad\quad i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
\end{aligned} \label{eq_3} \\[2ex]
%
&H_{21} = H_{12}       
\label{eq_4}
\end{align}
\end{document}

答案2

enter image description here

与来自alignmultlined环境的组合mathtools。我也不会将其用于\cdot乘法(括号内的项是相乘的,这是不言而喻的):

\documentclass{scrreprt}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\setcounter{chapter}{1} % just for this example
\begin{document}
\begin{align}
&   \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1}
        \leq h_i \leq
    \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k
    + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1},
     \qquad  i \in \mathcal{I}_{21}
    \label{eq_1}        \\[1em]
%
&   \begin{multlined}[0.7\linewidth]
    \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk}(s_{il} + \bar{s}_{il})
    (1 + \varepsilon) + w_i    \\
    + \sum_{j=I_1+1}^{I_2} \alpha_{ji}(s_{jk} + \bar{s}_{jk}) w_j
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik}),
    \qquad i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{multlined}
    \label{eq_2}        \\[1em]
%
&   \begin{multlined}[0.7\linewidth]
        \biggl( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\biggr)
            \biggl( w_i - \frac{1}{m+2} - \varepsilon -
            \abs*{w_i - \frac{1}{m+2} - \varepsilon}\biggr) \dotsm  \\
    \dotsm \biggl( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l
        - H_{12} - \varepsilon - \abs[\bigg]{h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk}
        \tilde{h}_l - H_{12} - \varepsilon }\biggr) = 0,    \\
        i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21}
    \end{multlined}
    \label{eq_3}    \\[1em]
%
&    H_{21} = H_{12}
    \label{eq_4}
\end{align}
\end{document}

答案3

您可以尝试使用aligned而不是split。这就是您想要的吗?

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
    \begin{aligned}
    \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & ,     i \in \mathcal{I}_{21}
    \end{aligned}
    \label{eq_1} \\
%
    \begin{aligned}
        \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    &   \\
        \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    & ,  i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \end{aligned} 
    \label{eq_2} \\
%
    \begin{aligned}   
        \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        & \\
        \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
        & , i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \end{aligned}
    \label{eq_3} \\
%
    H_{21} = H_{12} 
    &       
    \label{eq_4}
\end{align}
\end{document}

enter image description here

答案4

也许这更符合您的要求。我能够将最后一个等式拆分到括号中间(使用 $\left.$ 和 $\right.$),并且我选择使用水平间距来实现缩进。

\documentclass[]{scrreprt}
\usepackage{amsmath}

\begin{document}
\begin{align}
   & \sum_{k=K_1+1}^{K_{21}-1} s_{ik} \tilde{h}_{k+1} 
        \leq h_i 
        \leq \sum_{k=K_1+1}^{K_{21}} s_{ik} \tilde{h}_k 
             + \sum_{k=K_1+1}^{K_{21}-1} \bar{s}_{ik} \tilde{h}_{k+1}
    & , & i \in \mathcal{I}_{21}
    \label{eq_1} \\
%
   \begin{split}
       & \sum_{l=K_{21}+1}^{K_{22}} \alpha_{lk} (s_{il} + \bar{s}_{il}) \left( 1 + \varepsilon \right) 
            + w_i + \sum_{j=I_1+1}^{I_2} \alpha_{ji} (s_{jk} + \bar{s}_{jk}) w_j
    \\
       & \kern 2cm \geq (1 + \varepsilon)(1-s_{ik}-\bar{s}_{ik})
    \end{split} 
    & , & i \in \mathcal{I}_{22}, k \in \mathcal{K}_{22}
    \label{eq_2} \\
%
   \begin{split}   
        & \left( 1- \sum_{j=I_1+1}^{I_2}\alpha_{ji}t_{jk}\right) 
            \cdot \left( w_i - \frac{1}{m+2} - \varepsilon -|w_i - \frac{1}{m+2} - \varepsilon|\right) \cdot  \ldots 
        \\
        & \kern 2cm \ldots \cdot \left( h_i + \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon - 
        | h_i + \right.
        \\
        & \kern 3.85cm \left. \sum_{l=K_1+1}^{K_2} \alpha_{lk} \tilde{h}_l - H_{12} - \varepsilon | \right)
        = 0 
    \end{split}
    & , & i \in \mathcal{I}_{22}, k \in\mathcal{K}_{21} 
    \label{eq_3} \\
%
    & H_{21} = H_{12}       
    \label{eq_4}
\end{align}
\end{document}

enter image description here

相关内容