如何在对齐环境中删除公式前的空格?

如何在对齐环境中删除公式前的空格?
\begin{align}
    IP:Z =\Max \sum\limits_{j=1}^J  y_j\label{SoC1}\\
    \text{subject to} \notag \\
     \sum\limits_{l=1}^{L_k} x_{klm}=1\qquad k=1,2,...,K, m=1,2,....,M;\label{SoC2} \\
    \sum\limits_{m=1}^M y_{jm}\geq y_j\qquad          j=1,2,..,J,m=1,2,....,M;\label{SoC3}\\
    \sum\limits_{k=1}^K\sum\limits_{l=1}^{L_k}u^j_{kl} x_{klm} \geq h_j y_{jm}\qquad j=1,2,...J, m=1,2,...,M, \notag\\
k=1,2,...,K,\ell=1,2,...,\ell,...,L_k;\label{SoC4}
    \end{align}

我正在使用以下代码来构建数学模型。代码的前两行未正确对齐,并且太靠右了。我尝试了 {flalign},但它似乎仍然在同一个位置。任何帮助都非常感谢。

答案1

解决方案如下flalign

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{flalign}
  \qquad &  IP:Z  =\max ∑_{j=1}^J  y_j &    & \label{SoC1}\\[-1ex]
  \shortintertext{subject to}
  &  ∑_{l=1}^{L_k} x_{klm} =1, & &  k=1,2,\dots, K, &  m & =1,2,\dots,M; \label{SoC2}\\%
  &   ∑_{m=1}^M y_{jm} \geq y_j ,      & &  j=1,2,\dots, J,  & m & =1,2,\dots,M;\label{SoC3}\\%
  &  ∑_{k=1}^K∑_{l=1}^{L_k}u^j_{kl} x_{klm} \geq h_j y_{jm}, & &  j=1,2,\dots , J,\!  &m&=1,2,\dots,M,\notag \\[-2ex]
  &  &  & k=1,2,\dots,K, & \ell & =1,2,\dots, \ell,\dots,L_k.\label{SoC4}
\end{flalign}

\end{document}

在此处输入图片描述

答案2

不知道这是否是你要找的:

:D

来源:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % Fontencoding: 7bit -> 8bit
\usepackage{lmodern}
\usepackage{amsmath}
\begin{document}
\begin{align}
IP:Z = \sum\limits_{j=1}^J  y_j& \label{SoC1}\\
\text{subject to} \notag \\
\sum\limits_{l=1}^{L_k} x_{klm}&=1\qquad
& k=1,2,...,K, m=1,2,....,M;\label{SoC2} \\
\sum\limits_{m=1}^M y_{jm}&\geq y_j\qquad
& j=1,2,..,J,m=1,2,....,M;\label{SoC3}\\
\sum\limits_{k=1}^K\sum\limits_{l=1}^{L_k}u^j_{kl} x_{klm} &\geq h_j y_{jm}\qquad
& j=1,2,...J, m=1,2,...,M, \notag\\
&&k=1,2,...,K,\ell=1,2,...,\ell,...,L_k;\label{SoC4}
\end{align}
\end{document}

您需要在 align- 环境中使用&对齐。否则,latex 不知道该如何对齐。

相关内容