beamer 中的 \pause 正在改变定理计数器,从而产生问题

beamer 中的 \pause 正在改变定理计数器,从而产生问题

在一次演讲中,我向朋友要了一个beamer模板,他建议我使用这个模板。我照做了。我的主管建议我\pause在必要时使用,但在使用过程中,\pause我意识到定理计数器每次都会发生变化,\pause这会产生问题。我该如何修改此代码以确保不会\pause影响定理编号。这是我的演示文稿的主要代码,在代码的最后,我使用了两个章节,我正在\input{chapter1}其中\input{chapter2}编写演示文稿的主要内容。我尝试参考 TeX.SE 上的其他链接,但它不起作用。

\documentclass[notheorems]{beamer}
\setbeamertemplate{theorem}[ams style]
\setbeamertemplate{theorems}[numbered]
\makeatletter
\newcounter{theoremcnt}
\ifbeamer@countsect
\newtheorem{theorem}[theoremcnt]{\translate{Theorem}}[section]
\else
\newtheorem{theorem}[theoremcnt]{\translate{Theorem}}
\fi

\newcounter{saveenumi}
\newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}}
\newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}

\resetcounteronoverlays{saveenumi}
\newcounter{corollarycnt}
\newtheorem{corollary}[corollarycnt]{\translate{Corollary}}
\newcounter{factcnt}
\newtheorem{fact}[factcnt]{\translate{Fact}}
\newcounter{lemmacnt}
\newtheorem{lemma}[lemmacnt]{\translate{Lemma}}
\newcounter{problemcnt}
\newtheorem{problem}[problemcnt]{\translate{Problem}}
\newcounter{solutioncnt}
\newtheorem{solution}[solutioncnt]{\translate{Solution}}

\theoremstyle{definition}
\newcounter{definitioncnt}
\newtheorem{definition}{\translate{Definition}}
\newtheorem{definitions}{\translate{Definitions}}

\theoremstyle{example}
\newcounter{examplecnt}
\newtheorem{example}[examplecnt]{\translate{Example}}
\newtheorem{examples}[examplecnt]{\translate{Examples}}

% Compatibility
\newtheorem{Beispiel}[examplecnt]{Beispiel}
\newtheorem{Beispiele}[examplecnt]{Beispiele}
\theoremstyle{plain}
\newtheorem{Loesung}[solutioncnt]{L\"osung}
\newtheorem{Satz}[theoremcnt]{Satz}
\newtheorem{Folgerung}[lemmacnt]{Folgerung}
\newtheorem{Fakt}[factcnt]{Fakt}
\newenvironment{Beweis}{\begin{proof}[Beweis.]}{\end{proof}}
\newenvironment{Lemma}{\begin{lemma}}{\end{lemma}}
\newenvironment{Proof}{\begin{proof}}{\end{proof}}
\newenvironment{Theorem}{\begin{theorem}}{\end{theorem}}
\newenvironment{Problem}{\begin{problem}}{\end{problem}}
\newenvironment{Corollary}{\begin{corollary}}{\end{corollary}}
\newenvironment{Example}{\begin{example}}{\end{example}}
\newenvironment{Examples}{\begin{examples}}{\end{examples}}
\newenvironment{Definition}{\begin{definition}}{\end{definition}}
\newtheorem{conjecture}{Conjecture} % New conjecture environment

\makeatother

\mode<presentation>
{
    \usetheme{Madrid}
    \usecolortheme{rose}
    \usefonttheme{serif}
    \setbeamertemplate{}{}
    \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage{comment}
\usepackage[utf8x]{inputenc}
\usepackage{ragged2e}
\usepackage{epsfig}
\usepackage{mathtools}
\usepackage{graphics}
\usepackage{xfrac}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{etoolbox}


\makeatletter
\newenvironment<>{proofs}[1][\proofname]{%
    \par
    \def\insertproofname{#1\@addpunct{.}}%
    \usebeamertemplate{proof begin}#2}
{\usebeamertemplate{proof end}}
\makeatother

\title[Annual Progress Seminar]{Cantor's Intersection Theorem}
\author{Rohit K}
\institute{Department of Mathematics, IIT X}
\date{30th September 2023}
\titlegraphic{\hfill\includegraphics[height=1.5cm]{iitxlogo.png}}

\begin{document}

\frame{\titlepage}
% Include your other frames or chapters here
\input{chapter1}
\input{chapter2}
\end{document}

答案1

您可以使用\resetcounteronoverlays{theoremcnt}以确保覆盖不会影响此计数器。您必须对每个自定义计数器执行相同的操作:

\documentclass[notheorems]{beamer}

\setbeamertemplate{theorem}[ams style]
\setbeamertemplate{theorems}[numbered]

\makeatletter
\newcounter{theoremcnt}
\ifbeamer@countsect
\newtheorem{theorem}[theoremcnt]{\translate{Theorem}}[section]
\else
\newtheorem{theorem}[theoremcnt]{\translate{Theorem}}
\fi
\resetcounteronoverlays{theoremcnt}


\makeatother

\mode<presentation>
{
    \usetheme{Madrid}
    \usecolortheme{rose}
    \usefonttheme{serif}
    \setbeamertemplate{}{}
    \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage{comment}
%\usepackage[utf8x]{inputenc}
\usepackage{ragged2e}
%\usepackage{epsfig}
\usepackage{mathtools}
%\usepackage{graphics}
\usepackage{xfrac}
%\usepackage{mathtools}
%\usepackage{graphicx}
%\usepackage{etoolbox}

\title[Annual Progress Seminar]{Cantor's Intersection Theorem}
\author{Rohit K}
\institute{Department of Mathematics, IIT X}
\date{30th September 2023}


\begin{document}

\begin{frame}
test
\pause
\begin{theorem}[optional title]
content...
\end{theorem}
\end{frame}

\end{document}

在此处输入图片描述

...或者你也可以直接使用 beamer 自己的定理。它们将自动与覆盖层配合使用:

\documentclass{beamer}

\setbeamertemplate{theorem}[ams style]
\setbeamertemplate{theorems}[numbered]

\makeatother

\mode<presentation>
{
    \usetheme{Madrid}
    \usecolortheme{rose}
    \usefonttheme{serif}
    \setbeamertemplate{}{}
    \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage{comment}
%\usepackage[utf8x]{inputenc}
\usepackage{ragged2e}
%\usepackage{epsfig}
\usepackage{mathtools}
%\usepackage{graphics}
\usepackage{xfrac}
%\usepackage{mathtools}
%\usepackage{graphicx}
%\usepackage{etoolbox}

\title[Annual Progress Seminar]{Cantor's Intersection Theorem}
\author{Rohit K}
\institute{Department of Mathematics, IIT X}
\date{30th September 2023}

\newtheorem{conjecture}{Conjecture}


\begin{document}

\begin{frame}
test
\pause
\begin{theorem}[optional title]
content...
\end{theorem}

\pause

\begin{conjecture}[optional title]
content...
\end{conjecture}
\end{frame}

\end{document}

在此处输入图片描述

相关内容