![在 beamer 的单帧中使用 onslide 命令来使用多个 tikz 图片](https://linux22.com/image/270746/%E5%9C%A8%20beamer%20%E7%9A%84%E5%8D%95%E5%B8%A7%E4%B8%AD%E4%BD%BF%E7%94%A8%20onslide%20%E5%91%BD%E4%BB%A4%E6%9D%A5%E4%BD%BF%E7%94%A8%E5%A4%9A%E4%B8%AA%20tikz%20%E5%9B%BE%E7%89%87.png)
我在 beamer 中的单个帧中有多张 tikz 图片。在第一张 tikz 图片中,我只能使用 overlay 和 onslide 命令。但是,对于第二张图片,我无法实现相同的效果。我想要的是从 onslide<4> 开始,我想显示第二张 tikz 图片上的内容。
框架内的示例代码如下:
\begin{frame}
\frametitle{Age of Water under dye from all Rivers}
\only<1->{\begin{tikzpicture}
\centering
\node [](0,0)(start){ \includegraphics[clip,trim=10 370 400 10,width=0.8\textwidth,height=0.85\textheight]{figures/dye-rivers}};
% \draw [step=0.5cm,thin,dotted] (-5,-4) grid(5,4);
% \node [circle]at (-4.5,0){0};
% \node [circle,radius=0.9cm,fill=red!30,] at (-4.5,0)(a){};
\onslide<2->{\draw [red,fill=red!30](-4.3,-0.2)circle(0.1cm);
\draw [red,fill=red!30](-3.3,0)circle(0.1cm);
\draw [red,fill=red!30](-2.5,-0.7)circle(0.1cm);
\draw [red,fill=red!30](-4.,-0.8)circle(0.1cm);
\draw [red,fill=red!30](-4.,-1.2)circle(0.1cm);
\draw [red,fill=red!30](4.3,1.6)circle(0.1cm);
\draw [red,fill=red!30](3.3,2.7)circle(0.1cm);
\draw [red,fill=red!30](1.6,3.5)circle(0.1cm);
\draw [red,fill=red!30](1.3,3.5)circle(0.1cm);}
\node [rectangle,text width=4cm,red] at (5.5,3) (return) {$Q_2 = 169 A^{0.616}$ \linebreak Mason et. al. 1998};
\onslide<3-> \node [rectangle,text width=4cm,red] at (5,0) (return) {Smaller near the source \linebreak Increases away from the source};
\onslide<3-> \draw [red](-3.3,-1.5) circle(0.7cm);%wolf bay small age
\end{tikzpicture}}
\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[clip,trim=400 370 0 0,width=0.8\textwidth,height=0.85\textheight]{figures/dye-rivers}};
\draw [step=0.5,dotted](-5,-4) grid (5,4);
\end{tikzpicture}
\end{frame}
答案1
覆盖规范\only<1->{<text>}
导致<text>
出现在全部从幻灯片 1 开始的幻灯片。如果您希望将 的出现限制<text>
在特定范围内,则可以使用类似\only<1,2,3>{<text>}
或更简单的方法,使用范围\only<1-3>{<text>}
(也可以使用更复杂的规范,例如\only<1-3,5-7,9>{<text>}
这意味着<text>
将出现在幻灯片1
到3
、5
到7
和9
)。部分9 创建覆盖层(特别是从第二小节开始)包含覆盖规范的详细信息。
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Age of Water under dye from all Rivers}
\only<1-3>{\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[height=4cm]{example-image-a}};
% \draw [step=0.5cm,thin,dotted] (-5,-4) grid(5,4);
% \node [circle]at (-4.5,0){0};
% \node [circle,radius=0.9cm,fill=red!30,] at (-4.5,0)(a){};
\onslide<2->{\draw [red,fill=red!30](-4.3,-0.2)circle(0.1cm);
\draw [red,fill=red!30](-3.3,0)circle(0.1cm);
\draw [red,fill=red!30](-2.5,-0.7)circle(0.1cm);
\draw [red,fill=red!30](-4.,-0.8)circle(0.1cm);
\draw [red,fill=red!30](-4.,-1.2)circle(0.1cm);
\draw [red,fill=red!30](4.3,1.6)circle(0.1cm);
\draw [red,fill=red!30](3.3,2.7)circle(0.1cm);
\draw [red,fill=red!30](1.6,3.5)circle(0.1cm);
\draw [red,fill=red!30](1.3,3.5)circle(0.1cm);}
\node [rectangle,text width=4cm,red] at (5.5,3) (return) {$Q_2 = 169 A^{0.616}$ \linebreak Mason et. al. 1998};
\onslide<3> \node [rectangle,text width=4cm,red] at (5,0) (return) {Smaller near the source \linebreak Increases away from the source};
\onslide<3> \draw [red](-3.3,-1.5) circle(0.7cm);%wolf bay small age
\end{tikzpicture}}
\only<4->{\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[height=4cm]{example-image-b}};
\draw [step=0.5,dotted](-5,-4) grid (5,4);
\end{tikzpicture}}
\end{frame}
\end{document}
仅作为示例,我更改了剪辑命令;在实际代码中恢复它们。