使用temporal
它可以在一张幻灯片上获得过渡效果。以下示例在其中一行上创建了一个错误。
本质上:
这确实有效:node at (ONE) [select on=<1>]{ONE}
这确实有效:node at (ONE) [select on=<3>]{ONE}
这确实有效:node at (ONE) [select on=<1-3>]{ONE}
这不起作用:node at (ONE) [select on=<1,3>]{ONE}
\documentclass[c]{beamer}
\usepackage{tikz,times}
\begin{document}
\begin{frame}[fragile]
\newcommand{\magic}{1}
\newcommand{\interesting}{2}
\newcommand{\selected}{3}
\resizebox{0.485\textwidth}{!}{
\begin{tikzpicture}[baseline={(ONE.base)}]
\tikzset{
normal/.style={fill=white, align=center, draw},
selected/.style={fill=orange, align=center, thick, draw},
temporal/.code args={<#1>#2#3#4}{\temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}},
select on/.style={temporal=#1{normal}{selected}{normal}}
}
\coordinate (ONE) at (0,0);
\coordinate (TWO) at (4,1);
\coordinate (THREE) at (8,-1);
\draw (ONE) -- (TWO) -- (THREE);
\draw
%ERROR HERE
node at (ONE) [select on=<\magic,\selected>]{ONE}
%node at (ONE) [select on=<1,3>]{ONE} <- same error
%node at (ONE) [select on=<\magic>]{ONE} <- no error
node at (TWO) [select on=<\interesting>]{TWO}
node at (THREE) [select on=<\selected>]{THREE}
;
\end{tikzpicture}
}
\begin{minipage}[t]{0.485\textwidth}
\scriptsize
\begin{overprint}
\onslide<\magic>
\textcolor{orange}{\emph{Magic}} --
The selected nodes are magic, the audience applaudes.
\onslide<\interesting>
\textcolor{orange}{\emph{Interesting}} --
The selected nodes are interesting, an author wrote a book.
\onslide<\selected>
\textcolor{orange}{\emph{Selected}} --
The selected nodes are selected. This may or may not be obvious.
\end{overprint}
\end{minipage}
%DO NOT INDENT THE END OF A FRAGILE FRAME
\end{frame}
\end{document}
为了按照我想要的方式对我的数据进行排序和呈现,我需要在演示文稿中以不同的方式多次显示选择。
我该如何解决这个问题才能让它正常node at (ONE) [select on=<\magic,\selected>]{ONE}
工作。除了 1 和 3 幻灯片之外,其他幻灯片都正常,其中节点显示为选中状态。
答案1
问题在于<,>
,里面的逗号会使 tikz 解析器感到困惑,无法将其作为键分隔符。
解决方案是将该部分括在括号中,即:
\draw
node at (ONE) [select on=<{\magic,\selected}>]{ONE}
...;