我在 中的框架上有一个图表beamer
,用 绘制tikz
,我想在一段时间后将其拆除。原始图表如下所示:
\begin{frame}{Eksempel}
\begin{tikzpicture}[node distance=1.45cm, thick,
main node/.style={circle, draw, font=\sffamily\bfseries}]
\node[main node] (1) {1};
\node[main node] (3) [below left of=1] {3};
\node[main node] (4) [below right of=1] {4};
\node[main node] (2) [above right of=4] {2};
\node[main node] (6) [below right of=4] {6};
%\draw[->, visible on=<2->] (1) -- (2);
\path[->]
(1) edge (2)
(4) edge (2)
(6) edge (2)
(1) edge (3)
(4) edge (1)
(3) edge (4);
\end{tikzpicture}
\end{frame}
我想让边消失,并且在边消失后,没有更多边的节点会变成绿色。例如,在下一张幻灯片中,到节点 2 的所有边都应消失,而在下一张幻灯片中,节点 2 本身也应消失。
我尝试过visible on
或 之类的东西onslide
,但它们都给我错误消息。此外,也许可以使用\pause
,但如果我拆解图表而不是将内容放入其中,这会很奇怪。
答案1
这可以作为一个起点。
(在...的帮助下https://tex.stackexchange.com/a/6155/263192)
\documentclass{beamer}
\usepackage{tikz}
\tikzset{onslide/.code args={<#1>#2}{% from https://tex.stackexchange.com/a/6155/263192
\only<#1>{\pgfkeysalso{#2}}
}}
\begin{document}
\begin{frame}{Eksempel}
\begin{tikzpicture}[
node distance=1.45cm, thick,
main node/.style={circle, draw, font=\sffamily\bfseries}
]
\node[main node] (1) {1};
\node[main node] (3) [below left of=1] {3};
\node[main node] (4) [below right of=1] {4};
\node<-3>[main node,onslide=<3>{green}] (2) [above right of=4] {2};
\node<-4>[main node] (6) [below right of=4] {6}; % <-4> forces an additional overlay in which node 2 disappears
\path<1>[->] (1) edge (2)
(4) edge (2)
(6) edge (2);
\path[->] (1) edge (3)
(4) edge (1)
(3) edge (4);
\end{tikzpicture}
\end{frame}
\end{document}