![ビーマースライド上でコンテンツを進化させる: `scope` を使用して要素をグループ化する](https://rvso.com/image/405358/%E3%83%93%E3%83%BC%E3%83%9E%E3%83%BC%E3%82%B9%E3%83%A9%E3%82%A4%E3%83%89%E4%B8%8A%E3%81%A7%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%82%92%E9%80%B2%E5%8C%96%E3%81%95%E3%81%9B%E3%82%8B%3A%20%60scope%60%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E8%A6%81%E7%B4%A0%E3%82%92%E3%82%B0%E3%83%AB%E3%83%BC%E3%83%97%E5%8C%96%E3%81%99%E3%82%8B.png)
応募中です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}}