在投影機投影片上發展內容:使用「範圍」對元素進行分組

在投影機投影片上發展內容:使用「範圍」對元素進行分組

我正在申請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}}

相關內容