4

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} 
MKC
  • 93

3 Answers3

3

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}

\newcommand{\advanceparent}{%
  \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}}
\\
\advanceparent
&& 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)  \\
\advanceparent
&& c_1          &<   c_2 \\
&& b_1          &=   b_2
\end{alignat}
\end{subequations}
\lipsum[4]

\end{document} 

enter image description here

egreg
  • 1,121,712
  • I have tried to use your code, but I don't get the issue fixed you can see here: https://tex.stackexchange.com/questions/482588/subequations-equation-numbering-does-not-start-with-no-1 Maybe you can have a look at this one? Thanks a lot! – Dave Apr 01 '19 at 13:44
1

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}

enter image description here

Cragfelt
  • 4,005
  • I have corrected the errors. Can you please help with the reorganisation of equation number. – MKC Aug 07 '18 at 20:39
1

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_1p_1) \notag \ \eqmathboxr{\max_{p_2,x_1} \pi_C} &=\eqmathboxl{(p_2-c_2)(a_2-b_2p_2)-x_1r_1} \notag \ \eqmakebox[Mr][l]{s. t.}\notag \ \eqmathboxr{(a_1-b_1p_1)}&<(a_2-b_2p_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{equation} \begin{aligned} \eqmathboxr{c_1}&<\eqmathboxl{c_2}\ b_1&=b_2 \end{aligned} \end{equation}

\end{document}

enter image description here

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.

Bernard
  • 271,350
  • Thanks a lot @Bernard. Works perfectly. Can you please add few lines about the thought process you used. – MKC Aug 08 '18 at 05: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 08 '18 at 07:52