我有一张逐渐打开的幻灯片。假设它通常有 n 张幻灯片。但是“现在”我决定不从幻灯片 1 开始,而是从幻灯片 2 开始。尽管仍然显示了 n-1 张幻灯片,但 LaTeX 仍然认为它无法再找到标签定义!我该如何解决这个问题?
下面我提供了一个最小的例子。请注意,我复制了所有幻灯片,这样我就可以定义标签作为幻灯片的参数,也可以以“通常的方式”定义标签——只是为了表明这不会改变任何东西。
这里是代码:
\documentclass{beamer}
\begin{document}
\begin{frame}<2->{Title of Slide 1}\label{LabelOfSlideOne}
Slide 1 has three subslides, opened one by one, normally. Here, however, we start at slide number 2!
\begin{itemize}[<+->]
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
\begin{frame}<2->[label=LabelOfSlideTwo]{Title of Slide 2}
Slide 2 is exactly as slide 1, we simply define the label differently.
\begin{itemize}[<+->]
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
\begin{frame}{Title of Slide 3}\label{LabelOfSlideThree}
Slide 3 has two subslides, we show them incrementally, as normal.
\begin{itemize}[<+->]
\item 1
\item 2
\end{itemize}
\end{frame}
\begin{frame}[label=LabelOfSlideFour]{Title of Slide 4}
Slide 4 is exactly as slide 3, we simply define the label differently.
\begin{itemize}[<+->]
\item 1
\item 2
\end{itemize}
\end{frame}
\begin{frame}{Slide 5: Test all the references!}
\begin{itemize}
\item This should show a 1: \ref{LabelOfSlideOne}
\item This should show a 2: \ref{LabelOfSlideTwo}
\item This should show a 3: \ref{LabelOfSlideThree}
\item This should show a 4: \ref{LabelOfSlideFour}
\end{itemize}
\end{frame}
\end{document}
这就是结果:
这表明通常情况下定义标签可以完美运行(最后两张幻灯片),但当我们不显示所有幻灯片时(前两张幻灯片),它不起作用。
那么...如何解决这个问题?
答案1
有几种方法可以避免这个问题:
您可以在特定的覆盖层上指定标签,例如
\label<2>{LabelOfSlideOne}
您可以引用标签的特定覆盖,例如
\ref{LabelOfSlideTwo<2>}
\documentclass{beamer}
\begin{document}
\begin{frame}<2->{Title of Slide 1}\label<2>{LabelOfSlideOne}
Slide 1 has three subslides, opened one by one, normally. Here, however, we start at slide number 2!
\begin{itemize}[<+->]
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
\begin{frame}<2->[label=LabelOfSlideTwo]{Title of Slide 2}
Slide 2 is exactly as slide 1, we simply define the label differently.
\begin{itemize}[<+->]
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
\begin{frame}{Title of Slide 3}\label{LabelOfSlideThree}
Slide 3 has two subslides, we show them incrementally, as normal.
\begin{itemize}[<+->]
\item 1
\item 2
\end{itemize}
\end{frame}
\begin{frame}[label=LabelOfSlideFour]{Title of Slide 4}
Slide 4 is exactly as slide 3, we simply define the label differently.
\begin{itemize}[<+->]
\item 1
\item 2
\end{itemize}
\end{frame}
\begin{frame}{Slide 5: Test all the references!}
\begin{itemize}
\item This should show a 1: \ref{LabelOfSlideOne}
\item This should show a 2: \ref{LabelOfSlideTwo<2>}
\item This should show a 3: \ref{LabelOfSlideThree}
\item This should show a 4: \ref{LabelOfSlideFour}
\end{itemize}
\end{frame}
\end{document}