The subequations
environment & the parentequation
counter
The original subequations
environment redefines \theparentequation
in a way that it is independent from the counter parentequation
:
\protected@edef\theparentequation{\theequation}%
But we can redefine the subequations
environment so that only the value of equation
is saved and \theparentequation
uses the counter parentequation
again:
\def\theparentequation{\arabic{parentequation}}%
But that way we would loose the setting of \theequation
that might involve \thechapter
in classes like book
. For this, we could change it again manually to
\def\theparentequation{\thechapter.\arabic{parentequation}}%
etoolbox
and \patchcmd
Another approach uses etoolbox
and its \patchcmd
macro.
First we let \theparentequation
be the same as \theequation
:
\let\theparentequation\theequation
After that we look for every ocurrence of equation
and change it to parentequation
:
\patchcmd{\theparentequation}{equation}{parentequation}{}{}
At this point we don't need the \def
inition of \theparentequation
inside the subequations
environment anymore:
\usepackage{etoolbox}
% let \theparentequation use the same definition as equation
\let\theparentequation\theequation
% change every occurence of "equation" to "parentequation"
\patchcmd{\theparentequation}{equation}{parentequation}{}{}
\renewenvironment{subequations}{%
\refstepcounter{equation}%
% \def\theparentequation{\arabic{parentequation}}% we patched it already :)
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}%
\def\theequation{\theparentequation\alph{equation}}%
\ignorespaces
}{%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}
\nextParentEquation
Let me also define the command \nextParentEquation
that increments parentequation
and resets equation
so that we don't have to do this manually.
\newcommand*{\nextParentEquation}{%
\stepcounter{parentequation}\setcounter{equation}{0}%
}
Workaround for parentequation
labels (by OP Mobius Pizza)
While \label
directly after \begin{subequations}
works for referencing the first parent equation, to enable it to work after \nextParentEquation
it is necessary to define a alias command \parentlabel
for example, to evade sanitation performed by amsmath
:
\let\parentlabel\label
Addition by Qrrbrbirlbel
I didn't think of labeling the parentequations, but with OP's addition (see above), I would even go a step further and redefine the subequations
environment and the \nextParentEquation
so that they take on optional argment, the label's name.
Code
This MWE uses report
with one \chapter
to demonstrate that \thechapter.
doesn't get lost while redefining the subequations
environment, this also works with article
, of course.
\documentclass{report}
\usepackage{amsmath}
\usepackage{etoolbox}
% let \theparentequation use the same definition as equation
\let\theparentequation\theequation
% change every occurence of "equation" to "parentequation"
\patchcmd{\theparentequation}{equation}{parentequation}{}{}
\renewenvironment{subequations}[1][]{% optional argument: label-name for (first) parent equation
\refstepcounter{equation}%
% \def\theparentequation{\arabic{parentequation}}% we patched it already :)
\setcounter{parentequation}{\value{equation}}% parentequation = equation
\setcounter{equation}{0}% (sub)equation = 0
\def\theequation{\theparentequation\alph{equation}}%
\let\parentlabel\label% Evade sanitation performed by amsmath
\ifx\\#1\\\relax\else\label{#1}\fi% #1 given: \label{#1}, otherwise: nothing
\ignorespaces
}{%
\setcounter{equation}{\value{parentequation}}% equation = subequation
\ignorespacesafterend
}
\newcommand*{\nextParentEquation}[1][]{% optional argument: label-name for (first) parent equation
\refstepcounter{parentequation}% parentequation++
\setcounter{equation}{0}% equation = 0
\ifx\\#1\\\relax\else\parentlabel{#1}\fi% #1 given: \label{#1}, otherwise: nothing
}
\begin{document}
\chapter{Test}
\begin{equation}
0 \neq 1
\end{equation}
\begin{subequations}[eq:2]% or: \label{eq:2}
\begin{align}% or: \parentlabel{eq:2}
A & = B+1 \label{eq:2a} \\
B+1 & = C \label{eq:2b}
\intertext{therefore}\nextParentEquation[eq:3]% or: \nextParentEquation\parentlabel{eq:3}
A & = C \label{eq:3a} \\
B & = C-1 \label{eq:3b}
\end{align}
\end{subequations}
\eqref{eq:2}: \eqref{eq:2a}, \eqref{eq:2b} \\ \eqref{eq:3}: \eqref{eq:3a}, \eqref{eq:3b}
\begin{equation}
1 \neq 2
\end{equation}
\end{document}
Output

mathtools
provides the multlined
"subenvironment", which shifts the first line left,
the last line right, and applies only one number to each subequation.
put multiple multlined
subequations together with gather
:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\noindent X\hrulefill X\ignorespaces
\begin{subequations}
\label{energy13}
\begin{gather}
\begin{multlined}
u_e\frac{\partial \left(\varrho_e u_e\right)}{\partial t}
+ u_e\frac{\partial \left(\varrho_e u_e^2\right)}{\partial s}
+ u_e\frac{\partial \left(\varrho_e u_e v_e\right)}{\partial n}
-2 \varrho_e \varOmega u_e v_e \\
=- u_e\frac {\partial p_e}{\partial s}
+\qquad
+\varrho_e u_e\left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial
t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right)
\end{multlined}
\\
\begin{multlined}
u\frac{\partial \left(\varrho u\right)}{\partial t}
+ u\frac{\partial \left(\varrho u^2 \right)}{\partial s}
+ u\frac{\partial \left(\varrho u v \right)}{\partial n}
-2 \varrho \varOmega u v \\
=- u\frac {\partial p}{\partial s}
+\mu u\frac {\partial^2 u}{\partial n^2}
+\varrho u \left(\varOmega^2R_{OPs}+\frac{\partial\varOmega}{\partial
t}(R_{OPn}+n)-\frac{\partial^2 R_{Os}}{\partial t^2}\right)
\end{multlined}
\end{gather}
\end{subequations}
\end{document}

the equation numbers are centered vertically on the subequations, rather than being
set on the last line -- that's how all the "subenvironments" work.
Best Answer
another variation, with the equation number for each pair positioned vertically between the two lines: