# Equation number with subequation for few equations in align

I am trying to number equations where few equations are in two parts. For example, in this figure, I want equation '1a' to be '1' and equation '1b' and '1c' to be '2a' and '2b' respectively. Also, eqn '1d' and '1e' will together be eqn 3.

The code I am using right now is as follows:

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}

\begin{document}

\begin{subequations}
\begin{alignat}{2}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1) \notag \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1 \notag \\
\text{s. t.\enspace} \notag \\
(a_1-b_1p_1)&<(a_2-b_2*p_2)\\
p_1 & \le p_2 & & (\text{when } a_1\le a_2) \\
x_1r_1 & \le p_2 & & (\text{when } a_2 < a_1)\\
c_1&<c_2\\
b_1&=b_2
\end{alignat}
\end{subequations}
\end{document}


Does this suit you?

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{mathtools, nccmath}
\usepackage{eqparbox}
\newcommand{\eqmathboxr}[2][Mr]{\eqmakebox[#1][r]{$\displaystyle#2$}}
\newcommand{\eqmathboxl}[2][Ml]{\eqmakebox[#1][l]{$\displaystyle#2$}}

\begin{document}

\begin{align}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1) \notag \\
\eqmathboxr{\max_{p_2,x_1} \pi_C} &=\eqmathboxl{(p_2-c_2)(a_2-b_2*p_2)-x_1r_1} \notag \\
\eqmakebox[Mr][l]{s. t.}\notag \\
\eqmathboxr{(a_1-b_1p_1)}&<(a_2-b_2*p_2)
\end{align}
\vspace*{-6ex}
\begin{subequations}
\begin{align}
\eqmathboxr{p_1} & \le \eqmathboxl{p_2} \llap{(when $a_1\le a_2$)}\\
x_1r_1 & \le \eqmathboxl{p_2 } \llap{(when $a_2 < a_1$)}
\end{align}
\end{subequations}
\vspace*{-3ex}
\begin{aligned} \eqmathboxr{c_1}&<\eqmathboxl{c_2}\\ b_1&=b_2 \end{aligned}

\end{document}


Explanations: The general idea is to use three independent align environments, since it's not possible to a subequations environment for only some rows of an align environment, and make the alignment points of these environments the same thanks to the eqparbox package: I defined \eqmathboxr and \eqmathboxl commands, which just \eqmathbox commands defined by the package, with their content in math mode, display style, and flushright or flushleft respectively. These commands/boxes use tags (with default values) so that all boxes sharing the same tag have width equal to the widest content. I finally apply these commands to the most relevant left sides or right sides of the whole bunch of equations.

• Thanks a lot @Bernard. Works perfectly. Can you please add few lines about the thought process you used. – MKC Aug 8 '18 at 5:20
• @MKC: I've added some explanations for the general process. Hope it's clear, but feel free to ask for other details. – Bernard Aug 8 '18 at 7:52

You could do like this; however, I'm quite dubious about the multiple numbering of conditions.

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}

\usepackage{lipsum}

\stepcounter{parentequation}%
\setcounter{equation}{0}%
\xdef\theparentequation{\arabic{parentequation}}%
}

\begin{document}

\lipsum*[3]
\begin{subequations}\label{mkctest}
\begin{alignat}{3}
&\mathmakebox[3em][l]{
\begin{aligned}[b]
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1)
\\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1
\end{aligned}
} \notag \\
&\text{s. t.} \notag \\
&& (a_1-b_1p_1) &<   (a_2-b_2*p_2) \tag{\ref{mkctest}}
\\
&& p_1          &\le p_2            &\quad& (\text{when } a_1\le a_2) \\
&& x_1r_1       &\le p_2            &     & (\text{when } a_2 < a_1)  \\
&& c_1          &<   c_2 \\
&& b_1          &=   b_2
\end{alignat}
\end{subequations}
\lipsum[4]

\end{document}


There are extra & and a missing \\

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}

\begin{document}

\begin{subequations}
\begin{alignat}{2}
\max_{p_1} \pi_R &=(p_1-c_1)(a_1-b_1*p_1) \notag \\
\max_{p_2,x_1} \pi_C &=(p_2-c_2)(a_2-b_2*p_2)-x_1r_1 \notag \\
\text{s. t.\enspace} \notag \\
(a_1-b_1p_1)    &   <(a_2-b_2*p_2)  & \\
p_1             &   \le p_2         & (\text{when } a_1\le a_2) \\
x_1r_1          &   \le p_2         & (\text{when } a_2 < a_1) \\
c_1             &   <c_2            & \\
b_1             &   =b_2
\end{alignat}
\end{subequations}
\end{document}


• I have corrected the errors. Can you please help with the reorganisation of equation number. – MKC Aug 7 '18 at 20:39