对齐方程式并保持方程式编号?

对齐方程式并保持方程式编号?

我试图用数字写出多个方程,但当使用\begin{align}而不是时\begin{equation},数字消失了。这是我的方程,有些方程分成两行。我搜索过与我的问题类似的问题,但我无法解决这个问题。

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{siunitx} %
\usepackage{textcomp}
\usepackage{hyperref}
\begin{document}
%-------------------this is part from chapter 3 ------ 
    %objective eq1
    \begin{equation}
    \label{eq:3.1}
    Min \quad \sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{isrk}^{t} 
    \end{equation}
    Subjected to:
    %eq2
    \begin{equation}
    \label{eq:3.2}
    \vert{p_i}-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{isrk}^{t}\vert{} \leq \delta,\qquad\forall{i}\in\{{1,\ldots,N}\} \end{equation}
    %eq3
    \begin{equation} \label{eq:3.3} \sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G}  v_{isrk}^{t} \leq{L},\qquad 
    \forall {t} \in {\{{1,\ldots,T}\}} \end{equation}
    %eq4
    \begin{equation}\label{eq:3.4} \sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H}v_{isrk}^{t} +\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H}x_{isrk}^{t} \leq{1},\qquad \forall {t} \in {\{{1,\ldots,T}\}} \end{equation}
    %eq5
    \begin{equation} \label{eq:3.5}
        \begin{multlined}
        \sum_{i=1}^{N} x_{isrk}^{t} \leq \sum_{i=1}^{N}(u_{isrk}^{t}-u_{is(r+1)k}^{t}),\\ \qquad \forall {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H-1}\}},
        {k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}    
        \end{multlined}
    \end{equation} 
    %eq6
    \begin{equation}\label{eq:3.6}
        \begin{multlined}
        {\sum_{s^{'}=1 {,{s^{'}\neq s}}}^{N} \sum_{r=1}^{H} y_{i{s^{'}rk}}^{t}} \geq {\sum_{r=1}^{H}x_{isrk}^{t}},\\ \qquad \forall {i} \in {\{{1,\ldots,N}\}},{s} \in {\{{1,\ldots,C}\}},
        {k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}    
        \end{multlined}
    \end{equation} 
    %eq7
    \begin{equation}\label{eq:3.7}
        \begin{multlined}
        \sum_{i=1}^{N} v_{isrk}^{t} + \sum_{i=1}^{N} y_{isrk}^{t} +\sum_{i=1}^{N} x_{isrk}^{t} \leq {1}, \\ \qquad \forall {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H}\}},{k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}    
        \end{multlined}
    \end{equation}
\end{document}

在此处输入图片描述

感谢大家的评论,我尝试了以下方法,效果很好。现在方程式已对齐到页面左侧。

    \documentclass[12pt,twoside]{report}
    \usepackage[utf8]{inputenc}
    \usepackage{amssymb}
    \usepackage{amsmath}
    \usepackage{mathtools}
    \usepackage{siunitx} %
    \usepackage{textcomp}
    \usepackage{hyperref}
    \begin{document}
        %-------------------this is part from chapter 3 ------ 
    \begin{align}
    %objective eq1
    &\text{Objective:} \nonumber \\
    & Min \quad \sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{isrk}^{t}\label{eq:3.1} \\ 
    &\text{Subjected to} \nonumber \\
    %eq2
    &\vert{p_i}-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{isrk}^{t}\vert{} \leq \delta,\qquad\forall{i}\in\{{1,\ldots,N}\}\label{eq:3.2}\\
    &\begin{multlined}
    \sum_{i=1}^{N} x_{isrk}^{t} \leq \sum_{i=1}^{N}(u_{isrk}^{t}-u_{is(r+1)k}^{t}),\\ \qquad \forall {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H-1}\}},
    {k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}   
    \end{multlined}\label{eq:3.3}\\%eq3
    &\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H}v_{isrk}^{t} +\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H}x_{isrk}^{t} \leq{1},\qquad \forall {t} \in {\{{1,\ldots,T}\}}\label{eq:3.4}\\%eq4 
    &\begin{multlined} 
    \sum_{i=1}^{N} x_{isrk}^{t} \leq \sum_{i=1}^{N}(u_{isrk}^{t}-u_{is(r+1)k}^{t}),\\ \qquad \forall {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H-1}\}},{k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}\end{multlined}\label{eq:3.5}\\%eq5
    &\begin{multlined}
    {\sum_{s^{'}=1 {,{s^{'}\neq s}}}^{N} \sum_{r=1}^{H} y_{i{s^{'}rk}}^{t}} \geq {\sum_{r=1}^{H}x_{isrk}^{t}},\\ \qquad \forall {i} \in {\{{1,\ldots,N}\}},{s} \in {\{{1,\ldots,C}\}},{k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}\end{multlined}\label{eq:3.6} \\ %eq6 
    &\begin{multlined}
    \sum_{i=1}^{N} v_{isrk}^{t} + \sum_{i=1}^{N} y_{isrk}^{t} +\sum_{i=1}^{N} x_{isrk}^{t} \leq {1},\\ \qquad \forall {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H}\}},{k} \in {\{{1,\ldots,G}\}},{t} \in {\{{1,\ldots,T}\}}\end{multlined}\label{eq:3.7}\\%eq7
    & u_{isr1}^{1}=I_{isr},\qquad \forall {i} \in {\{{1,\ldots,N}\}}, {s} \in {\{{1,\ldots,C}\}},{r} \in {\{{1,\ldots,H}\}}\label{eq:3.8}\\
\end{align}
\end{document}

在此处输入图片描述

答案1

我的答案是使用特定的包optidef:一个用于优化问题的 LaTeX 库,带有[short]选项(带有短代码)和不带有选项(带有短代码)。

我已经清理了一下你的序言删除\usepackage{amsmath}并留下\usepackage{mathtools}这是一个至高无上包。我使用过:

\usepackage{geometry}
\usepackage{parskip}

只是为了平衡a4paper和没有段落开头的缩进空间。使用选项,mini!您可以创建子方程式,而没有,!您只有一个编号方程式。此外,我还使用了其他特定命令,例如\lvert\rvert,这是创建\abs命令的典型示例。


\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amssymb}

\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage[short]{optidef}
\usepackage{parskip}

\begin{document}
Objective:
\begin{mini!}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{\textup{isrk}}^{t} \protect \label{eq:3.1}}{}{}
\addConstraint {\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{\textup{isrk}}^{t}\rvert}{\leq \delta,}{\quad\forall{i}\in\{{1,\ldots, N}\}}
\addConstraint { \text{left side} }{=\text{right side},}{\quad \forall{i}\in\{{1,\ldots,N}\}}
\end{mini!}    

\begin{mini}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{\textup{isrk}}^{t} \protect \label{eq:3.2}}{}{}
\addConstraint {\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{\textup{isrk}}^{t}\rvert}{\leq \delta,}{\quad\forall{i}\in\{{1,\ldots, N}\}}
\addConstraint { \text{left side} }{=\text{right side},}{\quad \forall{i}\in\{{1,\ldots,N}\}}
\end{mini}    

\end{document}

在此处输入图片描述

删除选项[short],你将得到完整的文字(最小化并服从):

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{optidef}
\usepackage{parskip}

\begin{document}
Objective:
\begin{mini!}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{\textup{isrk}}^{t} \protect \label{eq:3.1}}{}{}
\addConstraint {\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{\textup{isrk}}^{t}\rvert}{\leq \delta,}{\quad\forall{i}\in\{{1,\ldots, N}\}}
\addConstraint { \text{left side} }{=\text{right side},}{\quad \forall{i}\in\{{1,\ldots,N}\}}
\end{mini!}    

\begin{mini}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{\textup{isrk}}^{t} \protect \label{eq:3.2}}{}{}
\addConstraint {\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{\textup{isrk}}^{t}\rvert}{\leq \delta,}{\quad\forall{i}\in\{{1,\ldots, N}\}}
\addConstraint { \text{left side} }{=\text{right side},}{\quad \forall{i}\in\{{1,\ldots,N}\}}
\end{mini}    

\end{document}

在此处输入图片描述

附录1:在好心用户@Zarko 的评论之后,我又加了一行写出 OP 在方程式中单独行输入的长条件

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{optidef}
\usepackage{parskip}

\begin{document}
Objective:
\begin{mini!}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{isrk}^{t} \protect \label{eq:3.1}}{}{}
\addConstraint{\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{isrk}^{t}\rvert}{\leq \delta,}{\qquad\forall{i}\in\{1,\ldots, N\}}
\addConstraint{\sum_{i=1}^{N} x_{isrk}^{t}\leq \sum_{i=1}^{N}(u_{isrk}^{t}-u_{is(r+1)k}^{t}),\protect \label{eq:3.3}}{\quad}{\quad\begin{matrix}
     \forall s \in \{1,\ldots,C\},\\
      r \in \{1,\ldots, H-1\}, \\
      k \in \{1,\ldots,G\}, \\
      t \in \{1,\ldots,T\} 
\end{matrix}}
\end{mini!}    
\end{document}

在此处输入图片描述

可以使用相同设计的机制来添加其他方程式。

附录2:鉴于@A阿扎布正如注释中所述,它\addConstraint有近 3 个参数。我进行了几次测试,在第一个参数中,您无法像在代码中那样拆分方程式。但在第三个参数中,您可以使用一些不完善且粗糙的技巧来实现您的要求。

\addConstraint{first argument}{second argument}{third argument}

参见部分:

\addConstraint{
        \sum_{i=1}^{N} v_{isrk}^{t} + \sum_{i=1}^{N} y_{isrk}^{t} +\sum_{i=1}^{N} x_{isrk}^{t}}{\leq 1}{\begin{matrix}
        & \\[3.5em]
       \hspace{-5cm} \forall i\in \{1,\ldots,N\}, s \in \{1,\ldots,C\},r \in\{1,\ldots,H\}\protect\label{eq:3.8}
        \end{matrix}}

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{optidef}
\usepackage{parskip}

\begin{document}
Objective:
\begin{mini!}
{}{\sum_{i=1}^{N} \sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} y_{isrk}^{t} \protect \label{eq:3.1}}{}{}
\addConstraint{\lvert p_i-\sum_{s=1}^{C} \sum_{r=1}^{H} \sum_{k=1}^{G} \sum_{t=1}^{T} v_{isrk}^{t}\rvert}{\leq \delta,}{\qquad\forall{i}\in\{1,\ldots, N\}}
\addConstraint{
    \sum_{i=1}^{N} v_{isrk}^{t} + \sum_{i=1}^{N} y_{isrk}^{t} +\sum_{i=1}^{N} x_{isrk}^{t}}{\leq 1}{\begin{matrix}
    & \\[3.5em]
   \hspace{-5cm} \forall i\in \{1,\ldots,N\}, s \in \{1,\ldots,C\},r \in\{1,\ldots,H\}\protect\label{eq:3.8}
    \end{matrix}}
\end{mini!}    
\end{document}

在此处输入图片描述

相关内容