# Subnumbering Equations Under the actual equation number

I am trying to write an optimization problem like below using eqnarray:

Max   z =a + b   (1)
s.t   a > 1
b < 4


But I want to write the sub-equation numbers as (1.a) and (1.b) like below:

Max   z =a + b   (1)
s.t   a > 1      (1.a)
b < 4      (1.b)


It's easy with alignat, using \tag for suppressing the advancement of the numbering and setting the referenced equation number instead.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{subequations}\label{eq:foo}
\begin{alignat}{2}
\max        &\quad& z &= a + b   \tag{\ref{eq:foo}} \\
\text{s.t.} &     & a &> 1 \\
&     & b &< 4
\end{alignat}
\end{subequations}

\end{document}


You can of course add labels also for the two conditions.

• i picked this answer as this looks easy for me. thanks @egreg – jhon_wick Sep 3 '15 at 20:33

First off: Don't use eqnarray. It's badly deprecated. Use one of the multi-line equation environments of the amsmath package instead.

If your formatting need is one-off, it's probably not worth the overhead to set up a separate environment. Instead, simply use \tag and \ref directives.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
\max   z =a + b   \label{eq:1} \\
\text{s.t.}\quad           a > 1     \tag{\ref{eq:1}a} \\
\end{gather}
\end{document}


If you need to use this more than once, you may wish to use combined equation (for the main equation) and gather or align (for the conditions) environments. (The advantage of combining these environments is that LaTeX will, if need be, find a good pagebreak.) E.g.,

\documentclass{article}
\usepackage{amsmath}
\newcommand\ajustspaceandequationnumber{%
\vspace{-\belowdisplayskip}
\vspace{-\abovedisplayskip}
$$\max z =a + b$$