1

I am trying to write more than one equation with numbering, but when using the \begin{align} instead of \begin{equation} the numbering disappears. Here are my equations with some split in two lines. I have searched for similar questions to my question but I couldn't solve the issue.

\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}

enter image description here

Thank you all for your comments, I have tried the following and It worked. Now the equations are aligned to the left side of the page.

    \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}

enter image description here

3
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – dexteritas
    Sep 24, 2021 at 11:47
  • 1
    What exactly do you mean by \begin{align} instead of \begin{equation} the numbering disappears, there are no align in your example
    – daleif
    Sep 24, 2021 at 11:51
  • Thanks @daleif , I tried \begin{align} and it worked, Please, give a comment on this if you have.
    – JohnWeck
    Sep 24, 2021 at 12:14

1 Answer 1

1

My answer use the specific package optidef: a LaTeX library for optimization problems with the [short] option (with the short code) and without it.

I have cleaned a bit your preamble deleting the \usepackage{amsmath} and leaving \usepackage{mathtools} that is a supremum package. I have used:

\usepackage{geometry}
\usepackage{parskip}

just to have an equilibrium for the a4paper and to have not the indent space to begin of a paragraph. Using the option mini! you create the subequations and without ! you have a only numbered equation. In addition I have used other specific commands like \lvert and \rvert, typical to create \abs command.


\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}

enter image description here

Deleting the option [short], you will have the full words (minimize and subject to):

\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}

enter image description here

Addendum 1: Just after the comment of nice user @Zarko I have put another row to write long condition which OP put in separate lines in equations.

\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}

enter image description here

The other equations can be added using a mechanism of the same design.

Addendum 2: Given the request of @A Azab as by comment the \addConstraint have almost 3 arguments. I have done several tests and in the first argument you can't split the equations like in your code. But in the third argument you can achieve your request with some unrefined and rough tricks.

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

See the part:

\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}

enter image description here

5
  • 1
    Nice answer (of course +1), however I wonder how you would suggest to write long condition which OP put in separate lines in equations?
    – Zarko
    Sep 24, 2021 at 16:52
  • 1
    Sorry, but I can't upvote twice :-). Good solution!
    – Zarko
    Sep 24, 2021 at 21:41
  • @Zarko LOL :-) ahahahahahhaha. There is not absolutely problem. My best regards to a very nice user.
    – Sebastiano
    Sep 24, 2021 at 21:43
  • 1
    Thanks, @Sebastiano , this is Awesome. it worked well. However, how I can split the long constraint in the same form as my equations in my question; so that the split part start from a new line under the main constraint instead of the matrix form?
    – JohnWeck
    Sep 25, 2021 at 9:33
  • @AAzab Hi, please, can you see the Addendum 2 if it corresponds to your request?
    – Sebastiano
    Sep 25, 2021 at 22:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .