![在投影機投影片上發展內容:使用「範圍」對元素進行分組](https://rvso.com/image/405358/%E5%9C%A8%E6%8A%95%E5%BD%B1%E6%A9%9F%E6%8A%95%E5%BD%B1%E7%89%87%E4%B8%8A%E7%99%BC%E5%B1%95%E5%85%A7%E5%AE%B9%EF%BC%9A%E4%BD%BF%E7%94%A8%E3%80%8C%E7%AF%84%E5%9C%8D%E3%80%8D%E5%B0%8D%E5%85%83%E7%B4%A0%E9%80%B2%E8%A1%8C%E5%88%86%E7%B5%84.png)
我正在申請https://tex.stackexchange.com/a/518585/114719我在多個投影機幻燈片上開發內容時用來scope
將元素分組:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{overlayarea}{\linewidth}{0.7\paperheight}
\centering
\begin{tikzpicture}
\useasboundingbox(-5.5,-.5)rectangle(6,5.5);%
\coordinate (O) at (0, 0);
\coordinate (A) at (5, 5);
\coordinate (B) at (-5, 5);
\begin{scope}<1->
\draw (O) -- (B);
\end{scope}
\begin{scope}<2->
\draw (O) -- (A);
\end{scope}
\draw<3> (A) -- (B);
% \begin{scope}<3>
% \draw (A) -- (B);
% \end{scope}
\end{tikzpicture}
\end{overlayarea}
\end{frame}
\end{document}
如果我還在最後一張投影片上對元素進行分組,則替換
\draw<3> (A) -- (B);
和
\begin{scope}<3>
\draw (A) -- (B);
\end{scope}
幻燈片數組會折疊到最後一張幻燈片。為什麼會這樣scope
?
答案1
如果您想要將某個範圍的版本包裝到 中\onslide
,您可以如下執行此操作:
\newenvironment<>{Scope}[1][]{\onslide#2\begingroup\begin{scope}[#1]}{%
\end{scope}\endgroup}
然後你可以使用\begin{Scope}<3> ... \end{Scope}
代替\begin{scope}<3> ... \end{scope}
,這有點錯誤並且不起作用,正如你所說。
例子:
\documentclass{beamer}
\usepackage{tikz}
\newenvironment<>{Scope}[1][]{\onslide#2\begingroup\begin{scope}[#1]}{%
\end{scope}\endgroup}
\begin{document}
\begin{frame}
\begin{overlayarea}{\linewidth}{0.7\paperheight}
\centering
\begin{tikzpicture}
\useasboundingbox(-5.5,-.5)rectangle(6,5.5);% unnecessary
\coordinate (O) at (0, 0);
\coordinate (A) at (5, 5);
\coordinate (B) at (-5, 5);
\begin{Scope}<1->[blue]
\draw (O) -- (B);
\end{Scope}
\begin{Scope}<2->
\draw (O) -- (A);
\end{Scope}
\begin{Scope}<3>
\draw (A) -- (B);
\end{Scope}
\end{tikzpicture}
\end{overlayarea}
\end{frame}
\end{document}
藍線僅顯示如何新增範圍選項。
我個人還是認為overlay-beamer-styles
,如圖所示這個答案Skillmon 的建議從長遠來看會有很大幫助,至少我在這類應用程式中經常使用它。
答案2
這是一個使用 的方法\uncover
,它用作(例如)\uncover<1->{..}
,大括號內的所有內容{..}
都顯示在幻燈片 2、幻燈片 1 及以後的幻燈片中。這是代碼:
\documentclass{beamer}
\usepackage{tikz}
\begin{document} \begin{frame} \begin{overlayarea}{\linewidth}{0.7\paperheight}
\centering
\begin{tikzpicture}
\useasboundingbox(-5.5,-.5)rectangle(6,5.5);
\coordinate (O) at (0, 0);
\coordinate (A) at (5, 5);
\coordinate (B) at (-5, 5);
\uncover<1->{\begin{scope}\draw (O) -- (B);\end{scope}}
\uncover<2->{\begin{scope}\draw (O) -- (A);\end{scope}}
\uncover<3>{\draw (A) -- (B);}
\end{tikzpicture}
\end{overlayarea} \end{frame} \end{document}
\uncover
如果您想在(例如)投影片 2 之後顯示範圍,但範圍的某些部分稍後會顯示,則可以嵌套該命令。在您的範例中,如果將以\uncover
下行替換以開頭的三行,則上述程式碼將給出相同的結果。我添加了縮排以顯示嵌套。
\uncover<1->{
\begin{scope}
\draw (O) -- (B);
\uncover<2->{
\begin{scope}
\draw (O) -- (A);
\uncover<3>{
\draw (A) -- (B);
}
\end{scope}}
\end{scope}}