可以将覆盖规范添加到 TikZ 命令中。
\node<2> (a) {only visible on slide 2};
这对于整个 tikzpicture 环境是否也有可能?
\begin{tikzpicture}[<2>]
\node (a) {only visible on slide 2};
\node (b) {also only visible on slide 2};
\end{tikzpicture}
这可以通过将环境封闭起来来模拟,但是当在中使用\only<2>{ ... }
时这是不可能的。tikzpicture
\newenvironment
答案1
visible on
与往常一样,由于Daniel 定义的风格,这些问题可以轻松解决(参见思维导图 tikzpicture 在 beamer 中 (逐步显示))。
此外,它在自定义环境中也能顺利运行。演示:
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\newenvironment{mytikz}[1][]{\begin{tikzpicture}[#1]}{\end{tikzpicture}}
\begin{document}
\begin{frame}
\begin{tikzpicture}[visible on=<2->]
\node at (0,0) (a) {only visible on slide 2};
\node at (2,2) (b) {also only visible on slide 2};
\end{tikzpicture}
Some text here:
\begin{itemize}
\item one
\item two
\end{itemize}
\begin{center}
\begin{mytikz}[visible on=<3>]
\draw[top color=orange,bottom color=magenta!80!purple]
(0,0) rectangle(2,1);
\draw[top color=magenta!80!purple,bottom color=green,radius=0.5]
(4,0.5) circle ;
\end{mytikz}
\end{center}
\end{frame}
\end{document}
结果: