# Nested subequations mess up equations counter

This working example:

\documentclass[a4paper]{report}

\usepackage{mleftright}
\usepackage{braket}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

they are related by Fourier transformation:
\begin{subequations}
\begin{subequations}
\label{Position-MomentumSpaceWaveFunctionsDiscr}
\begin{align}
\psi \mleft( x \mright) = \braket{x \vert \psi} = \braket{x \vert \hat{\mathbb{I}} \vert \psi} & = \braket{x \vert \mleft( \sum_{p' \in \mathscr{P}} \ket{p'} \bra{p'} \mright) \vert \psi} \notag \\
& = \sum_{p' \in \mathscr{P}} \braket { x \vert p' } \braket{ p' \vert \psi } = \sum_{p' \in \mathscr{P}} \braket { x \vert p' } \phi \mleft( p' \mright) \, , \label{PositionSpaceWaveFunctionsDiscr} \\
\phi \mleft( p \mright) = \braket{p \vert \psi} = \braket{p \vert \hat{\mathbb{I}} \vert \psi} & = \braket{p \vert \mleft( \sum_{x' \in \mathscr{X}} \ket{x'} \bra{x'} \mright) \vert \psi} \notag \\
& = \sum_{x' \in \mathscr{X}} \braket { p \vert x' } \braket{ x' \vert \psi } = \sum_{x' \in \mathscr{X}} \braket { p \vert x' } \psi \mleft( x' \mright) \label{MomentumSpaceWaveFunctionsDiscr}
\end{align}
\end{subequations}
or
\begin{subequations}
\label{Position-MomentumSpaceWaveFunctionsCont}
\begin{align}
\psi \mleft( x \mright) = \braket{x \vert \psi} = \braket{x \vert \hat{\mathbb{I}} \vert \psi} & = \braket{x \vert \mleft( \int\limits_{\mathscr{P}} \! \diff p' \, \ket{p'} \bra{p'} \mright) \vert \psi} \notag \\
& = \int\limits_{\mathscr{P}}\! \diff p' \, \braket { x \vert p' } \braket{ p' \vert \psi } = \int\limits_{\mathscr{P}}\! \diff p' \, \braket { x \vert p' } \phi \mleft( p' \mright) \, , \label{PositionSpaceWaveFunctionsCont} \\
\phi \mleft( p \mright) = \braket{p \vert \psi} = \braket{p \vert \hat{\mathbb{I}} \vert \psi} & = \braket{p \vert \mleft( \int\limits_{\mathscr{X}} \! \diff x' \, \ket{x'} \bra{x'} \mright) \vert \psi} \notag \\
& = \int\limits_{\mathscr{X}}\! \diff x' \, \braket { p \vert x' } \braket{ x' \vert \psi } = \int\limits_{\mathscr{X}}\! \diff x' \, \braket { p \vert x' } \psi \mleft( x' \mright) \, , \label{MomentumSpaceWaveFunctionsCont}
\end{align}
\end{subequations}
\end{subequations}
respectively, with $\braket{p' \vert x'} = \braket{x' \vert p'}^*$ as outlined in \eqref{InnerProduct} and $\mathscr{X}$ and $\mathscr{P}$ denoting the position and momentum eigenspectra. Orthonormality requires:
\newline
\begin{subequations}
\begin{minipage}[t]{0.5\textwidth}
$$\label{OrthoNormPositionKetsDiscr} \text{and }\braket{x_{1} \vert x} = \delta_{x_{1},x}$$
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
$$\label{OrthoNormPositionKetsCont} \braket{x_{1} \vert x} = \delta(x_{1}-x)$$
\end{minipage}\hfill
\end{subequations}
\newline
\newline
\newline
for position kets and also momentum eigenkets:

\end{document}


produces the following output:

whereas naturally the numbering should continue at 2.

In my actual document, the nested subequations are 1.30aa, 1.30ab, 1.30ba, and 1.30bb, respectively and the numbering 'resets' to 1.3a & 1.3b in the following subequations in one line.

How to fix this?

• it isn't supported and it seems a bit strange. you could use \tag and label by hand to just use normal equations and locally specify the equation counter formatting to get what you need – David Carlisle Jun 1 '20 at 15:53

Each subequations increment counter equations. Since you nested them, on the end the counter equation is increment twice. This you cen solve with addint \addtocounter{equation}{-1} ˙after end of outersubequations:

\documentclass[a4paper]{report}

\usepackage{mleftright}
\usepackage{braket}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

they are related by Fourier transformation:
\begin{subequations}
\begin{subequations}\label{Position-MomentumSpaceWaveFunctionsDiscr}
\begin{align}
\psi \mleft( x \mright) = \braket{x \vert \psi} = \braket{x \vert \hat{\mathbb{I}} \vert \psi}
& = \braket{x \vert \mleft( \sum_{p' \in \mathscr{P}} \ket{p'} \bra{p'} \mright) \vert \psi} \notag \\
& = \sum_{p' \in \mathscr{P}} \braket { x \vert p' } \braket{ p' \vert \psi } = \sum_{p' \in \mathscr{P}} \braket { x \vert p' } \phi \mleft( p' \mright) \, , \label{PositionSpaceWaveFunctionsDiscr} \\
\phi \mleft( p \mright) = \braket{p \vert \psi} = \braket{p \vert \hat{\mathbb{I}} \vert \psi}
& = \braket{p \vert \mleft( \sum_{x' \in \mathscr{X}} \ket{x'} \bra{x'} \mright) \vert \psi} \notag \\
& = \sum_{x' \in \mathscr{X}} \braket { p \vert x' } \braket{ x' \vert \psi } = \sum_{x' \in \mathscr{X}} \braket { p \vert x' } \psi \mleft( x' \mright) \label{MomentumSpaceWaveFunctionsDiscr}
\end{align}
\end{subequations}
or
\begin{subequations}
\label{Position-MomentumSpaceWaveFunctionsCont}
\begin{align}
\psi \mleft( x \mright) = \braket{x \vert \psi} = \braket{x \vert \hat{\mathbb{I}} \vert \psi} & = \braket{x \vert \mleft( \int\limits_{\mathscr{P}} \! \diff p' \, \ket{p'} \bra{p'} \mright) \vert \psi} \notag \\
& = \int\limits_{\mathscr{P}}\! \diff p' \, \braket { x \vert p' } \braket{ p' \vert \psi } = \int\limits_{\mathscr{P}}\! \diff p' \, \braket { x \vert p' } \phi \mleft( p' \mright) \, , \label{PositionSpaceWaveFunctionsCont} \\
\phi \mleft( p \mright) = \braket{p \vert \psi} = \braket{p \vert \hat{\mathbb{I}} \vert \psi} & = \braket{p \vert \mleft( \int\limits_{\mathscr{X}} \! \diff x' \, \ket{x'} \bra{x'} \mright) \vert \psi} \notag \\
& = \int\limits_{\mathscr{X}}\! \diff x' \, \braket { p \vert x' } \braket{ x' \vert \psi } = \int\limits_{\mathscr{X}}\! \diff x' \, \braket { p \vert x' } \psi \mleft( x' \mright) \, , \label{MomentumSpaceWaveFunctionsCont}
\end{align}
\end{subequations}
\end{subequations}
respectively, with $\braket{p' \vert x'} = \braket{x' \vert p'}^*$ as outlined in \eqref{InnerProduct} and $\mathscr{X}$ and $\mathscr{P}$ denoting the position and momentum eigenspectra. Orthonormality requires:
\newline
\begin{subequations}
\begin{minipage}[t]{0.5\textwidth}
$$\label{OrthoNormPositionKetsDiscr} \text{and }\braket{x_{1} \vert x} = \delta_{x_{1},x}$$
\end{minipage}%
\begin{minipage}[t]{0.5\textwidth}
$$\label{OrthoNormPositionKetsCont} \braket{x_{1} \vert x} = \delta(x_{1}-x)$$
\end{minipage}
\end{subequations}
\newline
\newline
\newline
for position kets and also momentum eigenkets:

\end{document}


• ok. In my overall document I have to add +28 and obviously adjust, if the count before changes. And the \newlines are actually also necessary - else it messes up the formatting – Markus Gratis Jun 1 '20 at 16:04
• @MarkusGratis, I focused only on numbering problem. Formatting of your document I left to you (now I see that I accidentally remove \newline` before mini pages). – Zarko Jun 1 '20 at 16:18
• no worries :) thanks for helping – Markus Gratis Jun 1 '20 at 16:22