1

I have the following latex code to write down a linear program:

\begin{alignat}{5} 
  \tag{$L(\mu)$} L(\mu) =  & \,\textrm{min}  && \,\sum_{h \in H} c_h x_h
  - \sum_{a \in A} \mu_a \sum_{h in H(a)} x_h
  + \sum_{a \in A} \mu_a y_a \\
  &&&- \sum_{t \in T} \mu_t \sum_{h \in H(t)} x_h
  + \sum_{t \in T} \mu_t       \nonumber    \\ 
  \tag{vehicle-flow}      &\textrm{s.t.} && \sum_{ a\in A(v)^{out}} y_a  &= \sum_{a \in A(v)^{in} } y_a  & \forall\, v \in V\\  
  \tag{x-space}           &              && 0                            &\leq x_{h} \leq 1              &\forall\, h \in H \\
  \tag{y-space}           &              && 0                            &\leq y_{a} \leq 1              &\forall\, a \in A 
 \end{alignat}$

As we can see, the length of the first equation leads to a bad alignment for the equations below. enter image description here

What I want to achieve:

  1. align "min" with "s.t."

  2. break the min-equation so that it does not become to long

  3. align the last three equations amongst themselves without extensive white space

  4. I don't want to do that by adding more alignment tabs to the first equation which would give me odd spacing between the sums

  5. I had a look into split environments but split does not allow me to have individual tags on my equations.

Thanks!

1 Answer 1

1

You can cheat more things between two alignment tabs without increasing their horizontal separation by putting stuff into \makebox blocks. The following example shows how you can use that to arrange your formulas in the way you want*:

\documentclass{article}
\usepackage{amsmath}

\newlength\stextwidth
\newcommand\makesamewidth[3][c]{%
  \settowidth{\stextwidth}{#2}%
  \makebox[\stextwidth][#1]{#3}%
}

\begin{document}

\begin{alignat}{4}
    L(\mu)=\min&\makebox[0pt][l]{$\displaystyle\sum_{h \in H} c_h x_h- \sum_{a \in A} \mu_a \sum_{h \in H(a)} x_h+ \sum_{a \in A} \mu_a y_a$} \tag{$L(\mu)$} \\
    &\makebox[0pt][l]{$\displaystyle- \sum_{t \in T} \mu_t \sum_{h \in H(t)} x_h + \sum_{t \in T} \mu_t$} \notag \\
    \makesamewidth[l]{$\min$}{s.t.}&\sum_{ a\in A(v)^{\textrm{out}}} y_a = \sum_{a \in A(v)^{\textrm{in}} } y_a&&\,\forall\, v \in V \tag{vehicle-flow} \\
    &&\makebox[0pt][r]{$0\leq x_{h} \leq 1$}&\,\forall\, h \in H \tag{x-space} \\
    &&\makebox[0pt][r]{$0\leq y_{a} \leq 1$}&\,\forall\, a \in A \tag{y-space}
\end{alignat}

\end{document}

enter image description here

*(I wasn't sure how you wanted the last three equations to be aligned, so I aligned them at the \forall sign).

Credits for \makesamwidth go to this post.

0

You must log in to answer this question.

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