4

For typesetting a mathematical program I use the subequations environment to number the equations. The restrictions are aligned using the alignat environment (see MWE1).

What I would like to achieve is that the objective equation should be centred just the way it is centred in the equation environment, but without effecting the alignment of the restriction equations (desired alignment see MWE2).

The problem with MWE2 is the wrong vertical spacing between the objective equation and the s.t.line and the wrong numbering of the objective equation which should be the same as in MWE1.

Nonsense math. program as MWE1:

\documentclass{article}

\usepackage{mathtools}


\begin{document}
\begin{subequations}
\begin{alignat}{3}
    \shortintertext{Objective Function:}
                                                    \min x                                              \\
    \shortintertext{s.t.:}
                                                    &   \sum_{p \in P} (x_p + x_p) x_{a, m, l}                                      && \leq M       & \qquad &  , \forall p \in P           \\                                  
                                                    &   \sum_{q \in Q} x_q x_{a, m, l}                                      && \leq M       & \qquad &  , \forall q \in Q
\end{alignat}
\end{subequations}

\end{document}

Nonsense math. program as MWE2:

\documentclass{article}

\usepackage{mathtools}


\begin{document}
\noindent Objective Function:
\begin{equation}
\min x      
\end{equation}
\begin{subequations}
\begin{alignat}{3}
    \shortintertext{s.t.:}
                                                    &   \sum_{p \in P} (x_p + x_p) x_{a, m, l}                                      && \leq M       & \qquad &  , \forall p \in P           \\                                  
                                                    &   \sum_{q \in Q} x_q x_{a, m, l}                                      && \leq M       & \qquad &  , \forall q \in Q
\end{alignat}
\end{subequations}

\end{document}
2

The simplest way is to use gather and alignat, removing the vertical space. The minipage is for avoiding page breaks; gather instead of equation ensures that \abovedisplayskip is used anyway (and never \abovedisplayshortskip).

\documentclass{article}

\usepackage{mathtools}

\begin{document}
\begin{subequations}
\noindent\begin{minipage}{\textwidth}
Objective Function:
\begin{gather}
\min x
\end{gather}
\vspace{-\belowdisplayskip}
\vspace{-\abovedisplayskip}
\begin{alignat}{3}
\shortintertext{s.t.:}
   & \sum_{p \in P} (x_p + x_p) x_{a, m, l} && \leq M & \qquad & , \forall p \in P \\
   & \sum_{q \in Q} x_q x_{a, m, l}         && \leq M & \qquad & , \forall q \in Q
\end{alignat}
\end{minipage}
\end{subequations}

\end{document}

enter image description here

2
  • Thank you for the solution. I used your solution without the minipage, because the spacing before and after that page was missing and I had a problem with the addmargin env. which includes the subequations env. One problem I still have is that the spacing between the gather and alignat environment seems now to be available for stretching when latex wants to fill a site. But the space between these two environments should always remain the same. Any idea? – user2653422 Aug 26 '14 at 10:31
  • @user2653422 The stretchable space is caused by \shortintertext. – egreg Aug 26 '14 at 12:09

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.