更改投影机中的定义数字

更改投影机中的定义数字

在 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即可:-1theorem

\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它提供将\labels 分配给计数器的功能。它允许人们以简单的方式“回忆”较旧的结构:

在此处输入图片描述

\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}

相关内容