Beamer - 检查某一帧的幻灯片编号

Beamer - 检查某一帧的幻灯片编号

我正在用 Beamer 准备一个小型演示文稿,其中我在帧之间使用带有计数器记忆的枚举。问题是,从第二帧开始,编号开始消失。我认为这是因为对帧的每一张幻灯片都执行了以下命令:

\setcounter{enumi}{\thecurrentenumi}

那么,我的问题是,是否有人知道如何有条件地仅在给定框架的幻灯片 #1 上执行此命令?以下是两个框架的示例:

\documentclass[aspectratio=169, 14pt, notes]{beamer}
\newcounter{currentenumi}

\begin{document}
  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle{frame 1}

    \footnotesize

    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}

      \onslide<1->  \item Some text for frame 1 - slide 1
      \onslide<2->  \item Some text for frame 1 - slide 2
      \onslide<3->  \item Some text for frame 1 - slide 3
      \onslide<4->  \item Some text for frame 1 - slide 4

      \setcounter{currentenumi}{\theenumi}
    \end{enumerate}
  \end{frame}

  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle{frame 2}

    \footnotesize

    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}

      \setcounter{enumi}{\thecurrentenumi}

      \onslide<1->  \item Some text for frame 2 - slide 1
      \onslide<2->  \item Some text for frame 2 - slide 2
      \onslide<3->  \item Some text for frame 2 - slide 3
      \onslide<4->  \item Some text for frame 2 - slide 4

      \setcounter{currentenumi}{\theenumi}
    \end{enumerate}
  \end{frame}
\end{document}

这是我得到的,其中红色部分是我应该得到的。 错误编号的枚举 感谢您的帮助,

答案1

尝试将你的\setcounter命令放在框架之间,如下所示:

\documentclass[aspectratio=169, 14pt, notes]{beamer}
\newcounter{currentenumi}

\begin{document}
  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle{frame 1}
    \footnotesize
    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}%
      \onslide<1->  \item Some text for frame 1 - slide 1
      \onslide<2->  \item Some text for frame 1 - slide 2
      \onslide<3->  \item Some text for frame 1 - slide 3
      \onslide<4->  \item Some text for frame 1 - slide 4
    \end{enumerate}
  \end{frame}
      \setcounter{currentenumi}{\theenumi}
  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle{frame 2}
    \footnotesize
    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}%
      \setcounter{enumi}{\thecurrentenumi}%
      \onslide<1->  \item Some text for frame 2 - slide 1
      \onslide<2->  \item Some text for frame 2 - slide 2
      \onslide<3->  \item Some text for frame 2 - slide 3
      \onslide<4->  \item Some text for frame 2 - slide 4
    \end{enumerate}
  \end{frame}
\setcounter{currentenumi}{\theenumi}
  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle{frame 3}
    \footnotesize
    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}%
      \setcounter{enumi}{\thecurrentenumi}%
      \onslide<1->  \item Some text for frame 2 - slide 1
      \onslide<2->  \item Some text for frame 2 - slide 2
      \onslide<3->  \item Some text for frame 2 - slide 3
      \onslide<4->  \item Some text for frame 2 - slide 4
    \end{enumerate}
  \end{frame}
\end{document}

答案2

问题是,您在每个覆盖层上都覆盖了计数器,因此下一个覆盖层上的计数器会出错。为了防止这种情况,您可以这样做\only<4>{\setcounter{currentenumi}{\theenumi}}

如果使用单帧,则可以避免保存计数器的所有麻烦:

\documentclass[aspectratio=169, 14pt]{beamer}
\setbeameroption{show notes}
\newcounter{currentenumi}

\begin{document}
  \begin{frame}[t]
    \frametitle{Simulation of my problem}
    \framesubtitle<1-4>{frame 1}
    \framesubtitle<5-9>{frame 2}

    \footnotesize

    \begin{enumerate}
      \setlength{\itemsep}{0.7cm}

      \item<1-4|only@1-4> Some text for frame 1 - slide 1
      \item<2-4|only@1-4> Some text for frame 1 - slide 2
      \item<3-4|only@1-4> Some text for frame 1 - slide 3
      \item<4|only@1-4> Some text for frame 1 - slide 4

      \item<5-9|only@5-9> Some text for frame 2 - slide 1
      \item<6-9|only@5-9> Some text for frame 2 - slide 2
    \end{enumerate}
  \end{frame}
\end{document}

在此处输入图片描述

相关内容