# How to align a linear program equations that has subequation and equation tags

I am using subequations and equation tags so I can number the objective function with (1) and all others constraints with (1a) (1b) and so on. However, the problem is that when I use these tags I don't get an aligning just like the solution on this page: here

Here is a minimal example:

\documentclass[conference]{IEEEtran}
\usepackage{amsmath}

\begin{document}

\begin{subequations}\label{MCRequation:main}
$$\text{min} \quad F \left( x \right) = \sum _{d \in D_{}}^{} \sum _{p \in P_{d} }^{} \xi _{dp} x_{dp} \tag{\ref{MCRequation:main}}$$
\begin{align}
\sum _{p \in P_{d} }^{}x_{dp}= h_{d},  \quad &d \in D \label{MCRequation:d}\\
\sum _{d \in D~ }^{} \sum _{p \in P_{d} }^{} \delta _{dpl} x_{dp} \leq  c_{l}, \quad l \in L \label{MCRequation:c}
\end{align}
\end{subequations}

\end{document}

• Welcome! See tex.stackexchange.com/a/225520. – Schrödinger's cat Sep 10 at 4:42
• Unrelated: Note that \text{min} is probably not what you want here as it will be italic if the text outside math is italic, probably better to just use \min. – daleif Sep 10 at 10:36

Like this?

\documentclass[conference]{IEEEtran}
\usepackage{amsmath}

\begin{document}

\begin{subequations}\label{MCRequation:main}
\begin{align}
& \text{min}  && F(x) = \sum_{d \in D_{}}^{} \sum_{p \in P_d}^{} \xi _{dp} x_{dp}     &   & \tag{\ref{MCRequation:main}} \\
& \text{s.t.} && \sum_{p \in P_d}^{}x_{dp} = h_d,                                     & d & \in D \label{MCRequation:d}  \\
&             && \sum_{d \in D~}^{} \sum_{p \in P_d}^{} \delta_{dpl} x_{dp} \leq c_l, & l & \in L \label{MCRequation:c}
\end{align}
\end{subequations}

\end{document}


You can use the mini! environment, from the dedicated package optidef, which defines several possible layouts. By default, the objective function part is the first subequation, but you can easily have the parent equation number using \tag{some number}:

\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
\usepackage[short]{optidef}

\begin{document}

\begin{mini!}[2]
{}{F(x) = \sum_{d \in D_{}}^{} \sum_{p \in P_d}^{} \xi _{dp} x_{dp}\tag{1} \label{MCRequation:d}}{\label{MCRequation:d}}{}
%
\addConstraint{ \sum_{p \in P_d}^{}x_{dp} = h_d, }{\enspace d \in D \label{MCRequation:d}}
\addConstraint{ \sum_{d \in D~} \sum_{p \in P_d} \delta_{dpl} x_{dp} \leq c_l,}{\enspace l \in L \label{MCRequation:c}}
\end{mini!}

\end{document}