I used to do this according to Andrew's solution until I read his note #2, and it reminded me that PGF's keys can do pretty much anything. The key (excuse the pun) is to create a key that processes other keys conditional on the slide number:
\tikzset{onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}}
}}
Using \pgfkeysalso
doesn't reset the current key path, whereas \pgfkeys
or \tikzset
would. The .code args
key handler means that
onslide=<overlay specification>{keys}
causes the the following code to be expanded:
\only<overlay specification>{\pgfkeysalso{keys}}
Then you can use the key onslide=<overlay specification>{keys}
to set keys only on specific slides. The slightly inelegant twist is that if your overlay specification contains commas the entire pair of overlay spec and keys has to be embraced.
Here is a complete example:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}} % \pgfkeysalso doesn't change the path
}}
\tikzset{temporal/.code args={<#1>#2#3#4}{%
\temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}} % \pgfkeysalso doesn't change the path
}}
\tikzstyle{highlight}=[red,ultra thick]
\begin{document}
\begin{frame}
\begin{figure}[h]
\begin{centering}
\begin{tikzpicture}[
system/.style={draw,rectangle,rounded corners=3,minimum width=2cm,text width=1.8cm,text centered},
node distance=2cm
]
\node [system,onslide=<3->{highlight},anchor=center] (fe) {Feature Extraction};
\node [system,onslide={<2,4>{green}}] (am) [right=of fe.center] {Acoustic Model};
\node [system,temporal=<3>{blue}{highlight}{green}] (lm) [right=of am.center] {Language Model};
\node [system] (d) [below=of lm.center] {Decoder};
\draw[->] (fe) |- (am);
\draw[->] (am) |- (d);
\draw[->] (lm) -- (d.north);
\end{tikzpicture}
\end{centering}
\end{figure}
\end{frame}
\end{document}
You will be disappointed about the jiggling of your picture when the line thickness keys are applied. You might have to avoid relative positioning to make that go away.
For more on key handlers like .code args
, see the pgfkeys
section of the TikZ-PGF manual.
It appears to me Till got confused: your third example shouldn't work at all if \action
wrapped its argument in the actionenv, not passing it as an argument to actioncommand.
Using
\newcommand<>\gray[1]{%
\textcolor#2{gray}{#1}%
}
appears to work. (FYI: the ?all:2! that you observe was the < all:2 > specification that was not being taken up because no command \gray existed to parse it. (The inverted ? and ! happen to sit in the spaces for > and < if you don't use the T1 fontencoding. Even more tangentially, if you ever see ?From in a scientific paper and have to laugh, you know enough about TeX and RFC822 to qualify as a hopeless geek.)
Best Answer
You can use the
\only
notation and theulem
package for strike through. The code would look like this:Update: Alternatively, you can use beamer's facilities to create an overlay aware version of the
\sout
command. That is done as follows:This basically states that the argument to
\sout
should be struck through on slides matching the overlay specifier and should be shown normally on slides that don't match it. I like this method a little better, because it is more concise in the slides itself. Note that it plays nicely together with the overlay specifier on the item. That is, if you were to remove the overlay specifier on\item<3->
the Peace struck would be shown without being struck through on slides 1 and 2 as well. The original method still works as well after the redefinition of\sout
.