以下 MWE 包含编号为 (2) 至 (4) 的方程的证明。我使用环境构造证明enumerate
,因此方程 (2) 的证明标记为2.
,方程 (3) 的证明标记为3.
,方程 (4) 的证明标记为4.
。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
An equation before the proof:
\begin{equation}
E = mc^2.
\end{equation}
%I might want another equation here:
%\begin{equation}
%a^2 + b^2 = c^2
%\end{equation}
Here is a list of equations we want to prove:
\begin{align}
F &= ma \label{eq:newton} \\
\tau &= r \times F \label{eq:torque} \\
I &= \frac{3}{17} MR^2. \label{eq:inertia}
\end{align}
We will prove the equations in order:
\begin{enumerate}
\setcounter{enumi}{2}
\addtocounter{enumi}{-1}
\item The first equation is trivial.
\item The second equation follows easily.
\item The third is left as an exercise to the reader.
\end{enumerate}
\end{document}
但是,如果我在要证明的方程列表之前添加另一个方程,编号可能会发生变化,例如,我现在正在证明方程 (3) 到 (5)。我希望环境中的编号enumerate
能够自动更改。但是,使用
\setcounter{enumi}{\ref{eq:newton}}
\addtocounter{enumi}{-1}
不起作用。
我怎样才能让enumerate
环境自动从特定方程的数字开始编号?
答案1
与其玩弄\addtocounter{enumi}
等等,不如使用它enumitem
和它的start=...
选择。
宏\getrefnumber{...}
提供refcount
了一种获取引用的真实“数字”的帮助——\ref
不可扩展并且会在这里失败。
请注意:这里\getrefnumber{...}
会产生任何数字,即某些事情也是可能的——然后就会失败。equation
1.A.5
start=...
\documentclass{article}
\usepackage{enumitem}
\usepackage{refcount}
\usepackage{amsmath}
\begin{document}
An equation before the proof:
\begin{equation}
E = mc^2.
\end{equation}
%I might want another equation here:
%\begin{equation}
%a^2 + b^2 = c^2
%\end{equation}
Here is a list of equations we want to prove:
\begin{align}
F &= ma \label{eq:newton} \\
\tau &= r \times F \label{eq:torque} \\
I &= \frac{3}{17} MR^2. \label{eq:inertia}
\end{align}
We will prove the equations in order:
\begin{enumerate}[start=\getrefnumber{eq:newton}]
\item The first equation is trivial.
\item The second equation follows easily.
\item The third is left as an exercise to the reader.
\end{enumerate}
\end{document}