在 beamer 演示中,我需要重新定义一个定义(定义编号必须相同)。我该怎么做?
这是我的代码。
\documentclass{beamer}
\setbeamertemplate{theorems}[ams style]
\begin{document}
\begin{frame}
\begin{definition}[A definition]
Some text.
\end{definition}
\begin{definition}[That definition again]
I need that definition number is repeated (it should be 1 instead of 2).
\end{definition}
\end{frame}
\end{document}
答案1
由于definition
基于,因此只需将添加到计数器theorem
即可:-1
theorem
\addtocounter{theorem}{-1}
梅威瑟:
\documentclass{beamer}
\setbeamertemplate{theorems}[ams style]
\begin{document}
\begin{frame}
\begin{definition}[A definition]
Some text.
\end{definition}
\addtocounter{theorem}{-1}
\begin{definition}[That definition again]
I need that definition number is repeated (it should be 1 instead of 2).
\end{definition}
\end{frame}
\end{document}
输出:
编辑
如果您有不相邻的,definition
我知道的唯一方法就是使用refcount
包。
在这里我使用命令\getrefnumber
来检索正确的数字。
\documentclass{beamer}
\setbeamertemplate{theorems}[ams style]
\usepackage{refcount}
\begin{document}
\begin{frame}
\begin{definition}[A definition]\label{def:first}
Some text.
\end{definition}
\begin{definition}[Another definition]\label{def:second}
Some text.
\end{definition}
\setcounter{theorem}{\getrefnumber{def:first}}\addtocounter{theorem}{-1}
\begin{definition}[That definition again]
I need that definition number is repeated (it should be 1 instead of 2).
\end{definition}
\setcounter{theorem}{\getrefnumber{def:second}}
\begin{definition}[One more definition]
Some text.
\end{definition}
\end{frame}
\end{document}
答案2
以下用途refcount
它提供将\label
s 分配给计数器的功能。它允许人们以简单的方式“回忆”较旧的结构:
\documentclass{beamer}% http://ctan.org/pkg/beamer
\setbeamertemplate{theorems}[ams style]
\usepackage{refcount}% http://ctan.org/pkg/refcount
\begin{document}
\begin{frame}
\begin{definition}[A definition]\label{first-def}
First definition.
\end{definition}
\begin{definition}[A new definition]\label{second-def}
Second definition.
\end{definition}
\setcounterref{theorem}{first-def}\addtocounter{theorem}{-1}% Adjust theorem counter
\begin{definition}[That definition again]
First definition again.
\end{definition}
\setcounterref{theorem}{second-def}% Restore theorem counter
\begin{definition}[Another new definition]
Third definition.
\end{definition}
\end{frame}
\end{document}