ビーマースライド上でコンテンツを進化させる: `scope` を使用して要素をグループ化する

ビーマースライド上でコンテンツを進化させる: `scope` を使用して要素をグループ化する

応募中ですhttps://tex.stackexchange.com/a/518585/114719scope複数の Beamer スライドにわたってコンテンツを開発する際に要素をグループ化するために使用します。

\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 の後にスコープを表示し、スコープの一部を後で表示したい場合などです。この例では、上記のコードで、 で始まる 3 行を\uncover次の行に置き換えると同じ結果が得られます。ネストを示すためにインデントを追加しました。

\uncover<1->{
  \begin{scope}
  \draw (O) -- (B);
  \uncover<2->{
    \begin{scope}
    \draw (O) -- (A);
    \uncover<3>{
      \draw (A) -- (B);
    }
  \end{scope}}
\end{scope}}

関連情報