如何在不同小节中延续方程编号?

如何在不同小节中延续方程编号?

我想继续对 beamer 中不同部分中的方程进行编号。示例如下:

Section 1
Subsection 1.1
Equation (1-1) % where equation number follows the pattern (subsection-equation number)
Section 2
Subsection 2.1
Equation (2-1)

我使用了\numberwithin{equation}{subsection},但是没有用。以下是测试文档的代码:

\documentclass{beamer}
% \usepackage{amsmath}
% Set equation numbers to include section and subsection
\numberwithin{equation}{subsection}
\renewcommand{\theequation}{\arabic{subsection}-\arabic{equation}}
\begin{document}
\begin{frame}
\section{First Section}
\subsection{First Subsection}
\begin{frame}{Frame Title}
An example equation in Section 1, Subsection 1.
\begin{equation} \label{S1:EQ1}
    a = b + c
\end{equation}
\end{frame}
\section{Second Section}
\subsection{First Subsection}
\begin{frame}{Another Frame Title}
An example equation in Section 2, Subsection 1.
\begin{equation} \label{S2:EQ1}
    e = mc^2
\end{equation}
As the equation \ref{S2:EQ1} lies in First Subsection of Second Section, can I have this equation numbered as (2-1)
\end{frame}
\end{document}

相关内容