2

I have this empheq code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{empheq}

\begin{document}
\begin{empheq}{align}
\min \quad & \displaystyle\sum_{t \in T}\sum_{(i,j,s) \in A^{t}} d_{ij}x^{t}_{ijs} \nonumber \\
    \textrm{s.a.}\quad & \sum_{i: (i,j,s-1) \in A^{t}} x^{t}_{ij,s-1} - \sum_{i: (j,i,s) \in A^{t}} x^{t}_{jis} = 0  &  \forall t,j \in T, s \in S \label{ip3r1} \\
    & \sum_{s \in S}\sum_{j:(i,j,s) \in A^{t}} x^{t}_{ijs} = 1   & \forall t \in T, i \in T \setminus \{t\} \label{ip3r2}\\
    & \sum_{u=0}^{U-1}\sum_{(i,j,s+u) \in B^{t}} x^{t}_{ij,s+u} \leq U-1 & \forall t \in T, s \in S: s \leq 2\bar{n}-U \label{ip3r3}\\
    & \sum_{i \in T -\{t\}}\sum_{j: (ijs \in A^{t})} x^{t}_{ijs} + \sum_{t^{\prime} \in T -\{t\}}\sum_{j: (tjs) \in A^{t^{\prime}}} x^{t^{\prime}}_{tjs} = 1  & \forall t \in T, s \in S \label{ip3r4}\\
    & x_{i} \in \{ 0,1\} & \forall i \in P \label{ip3vars}
\end{empheq}\label{ip3}

\end{document}

When building the pdf(on texmaker) the equation numbers go down:

labels are below instead of side

How can i bring the labels to the side??

  • This is due to how empheq is implemented, it is actually (in this case) an equation + aligned + code to number each line. In amsmath, if your math gets too close to the equation number it moves down. In this case all the eq numbers are one giant block and thus all moves down. As mentioned by others, there is no real reason to use empheq here as you're not emphasizing anything – daleif Oct 18 '18 at 4:53
1

Your equations are too long, due to the size of the indices in sums, and the default size of the margins. Here is a workaround, with the \smashoperator command from mathtools (loaded by empheq), and loading geometry which has more sensible default margins, if you don't use marginal notes.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}

\usepackage{empheq}%

\begin{document}

 \begin{empheq}{align}
\min \qquad & \displaystyle\sum_{t \in T}\sum_{(i,j,s) \in A^{t}} d_{ij}x^{t}_{ijs} \nonumber \\
\textrm{s.a.}\qquad & \smashoperator{\sum_{i: (i,j,s-1) \in A^{t}}} x^{t}_{ij,s-1} - \smashoperator{\sum_{i: (j,i,s) \in A^{t}}} x^{t}_{jis} = 0 & & \forall t,j \in T, s \in S \label{ip3r1} \\
  & \sum_{s \in S}\smashoperator[r]{\sum_{j:(i,j,s) \in A^{t}}} x^{t}_{ijs} = 1 & & \forall t \in T, i \in T \setminus \{t\} \label{ip3r2}\\
  & \sum_{u=0}^{U-1}\smashoperator[r]{\sum_{(i,j,s+u) \in B^{t}}} x^{t}_{ij,s+u} \leq U-1 & & \forall t \in T, s \in S: s \leq 2\bar{n}-U \label{ip3r3}\\
  & \smashoperator[l]{\sum_{i \in T -\{t\}}}\smashoperator[r]{\sum_{j: (i, j, s) \in A^{t}}} x^{t}_{ijs} + \sum_{t^{\prime} \in T -\{t\}}\smashoperator[r]{\sum_{j: (t, j, s) \in A^{\smash{t’}}}} x^{t’}_{tjs} = 1 & & \forall t \in T, s \in S \label{ip3r4}\\
    & x_{i} \in \{ 0,1\} & & \forall i \in P \label{ip3vars}
\end{empheq}\label{ip3}

\end{document} 

enter image description here

1

I'm not sure why using empheq in this case.

With a plain align, we can make some adjustments: the longest conditions are set in zero width boxes and, with some luck, they fit.

Also, the operand in the summations where the condition is long are pushed a bit to the left.

A couple of touches are \adjustlimits in condition 4 and a \mathstrut in condition 3, so the limits are aligned.

\documentclass{article}
\usepackage{amsmath,mathtools}

\newcommand{\nq}{\mspace{-12mu}} % negative spacing

\begin{document}

\begin{align}
\min\quad
& \sum_{t \in T}\sum_{(i,j,s) \in A^{t}} \nq d_{ij}x^{t}_{ijs} \nonumber \\
\mathrm{s.a.}\quad
& \sum_{i: (i,j,s-1) \in A^{t}} \nq x^{t}_{ij,s-1} -
  \sum_{i: (j,i,s) \in A^{t}} \nq x^{t}_{jis} = 0
  & \mathllap{\forall t,j \in T, s \in S}
\label{ip3r1} \\
& \sum_{s \in S}\sum_{j:(i,j,s) \in A^{t}} \nq x^{t}_{ijs} = 1
  & \mathllap{\forall t \in T, i \in T \setminus \{t\}}
\label{ip3r2}\\
& \sum_{u=0\mathstrut}^{U-1}\sum_{(i,j,s+u) \in B^{t}} \nq x^{t}_{ij,s+u} \leq U-1
  & \mathllap{\forall t \in T, s \in S: s \leq 2\bar{n}-U}
\label{ip3r3}\\
& \sum_{i \in T -\{t\}}\sum_{j: (ijs \in A^{t})} \nq x^{t}_{ijs} +
  \adjustlimits\sum_{t' \in T -\{t\}}\sum_{j: (tjs) \in A^{t'}} \nq x^{t'}_{tjs} = 1
  & \forall t \in T, s \in S
\label{ip3r4}\\
& x_{i} \in \{ 0,1\}
  & \forall i \in P
\label{ip3vars}
\end{align}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.