beamer:定理、例子、定义和引理的不同编号

beamer:定理、例子、定义和引理的不同编号

我想对定理、例子、定义和引理使用不同的编号。我在序言中使用以下代码

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

此代码运行良好,但定理和其他环境的编号连续。如果您能指导我如何在 中为定理、示例、定义和引理获取不同的编号,我将不胜感激beamer

答案1

beamer使用选项加载notheorems并“手动”声明所有定理类型,而不引入通用编号方案。(注意:这有点像 hack,因为它会破坏countsect除 之外的每种类型的包选项 [按节进行定理编号] theorem。)

\documentclass[notheorems]{beamer}

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

\makeatletter
    \ifbeamer@countsect
      \newtheorem{theorem}{\translate{Theorem}}[section]
    \else
      \newtheorem{theorem}{\translate{Theorem}}
    \fi
    \newtheorem{corollary}{\translate{Corollary}}
    \newtheorem{fact}{\translate{Fact}}
    \newtheorem{lemma}{\translate{Lemma}}
    \newtheorem{problem}{\translate{Problem}}
    \newtheorem{solution}{\translate{Solution}}

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

    \theoremstyle{example}
    \newtheorem{example}{\translate{Example}}
    \newtheorem{examples}{\translate{Examples}}


    % Compatibility
    \newtheorem{Beispiel}{Beispiel}
    \newtheorem{Beispiele}{Beispiele}
    \theoremstyle{plain}
    \newtheorem{Loesung}{L\"osung}
    \newtheorem{Satz}{Satz}
    \newtheorem{Folgerung}{Folgerung}
    \newtheorem{Fakt}{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}}
\makeatother

\begin{document}

\begin{frame}

\begin{theorem}[A theorem]
Some text.
\end{theorem}

\begin{definition}[A definition]
Some text.
\end{definition}

\end{frame}

\end{document}

enter image description here

相关内容