I read that: TikZ commands also accept Beamer overlay specifications, such as \draw<2-> (A) to (B); but I can not find any reference for it on the TikZ/PGF 3.0 manual. When I search for overlays in the +1000 page manual I got some other unrelated topic. Google and Bing were not helpful either. Please, could anyone indicate where I can find more details about overlay specifications in TikZ commands? If not in the manual, perhaps another reference then?
-
Perhaps you find something by looking throught tex.stackexchange.com/questions/tagged/tikz-pgf+beamer+overlays– samcarter_is_at_topanswers.xyzApr 29, 2014 at 16:29
-
@samcater thanks but off course I searched here before posting the question– Sergio ParreirasMay 2, 2014 at 21:57
1 Answer
Unfortunately, there's no mention of this fact neither in the PGF/TikZ
nor in the beamer
manuals (at least I couldn't find any reference).
The place where all the magic happens is the file tikz.code.tex
(located in .../tex/generic/pgf/frontendlayer/tikz/
) which contains the definitions for the front-end layer; there you'll find (lines 1833-1836):
\def\tikz@path@overlay#1{%
\let\tikz@signal@path=\tikz@signal@path% for detection at begin of matrix cell
\pgfutil@ifnextchar<{\tikz@path@overlayed{#1}}{\path #1}}
\def\tikz@path@overlayed#1<#2>{\path<#2> #1}
And also, some lines below (1938-1950), for filling/drawing:
\def\tikz@swap@args[#1]<#2>{\tikz@command@path<#2>[#1]}
\def\tikz@doopt{%
\let\tikz@next=\tikz@eargnormalsemicolon%
\ifnum\the\catcode`\;=\active\relax%
\let\tikz@next=\tikz@eargactivesemicolon%
\fi%
\tikz@next}
\long\def\tikz@eargnormalsemicolon<#1>#2;{\alt<#1>{\tikz@@command@path#2;}{\tikz@path@do@at@end}}
{
\catcode`\;=\active
\long\global\def\tikz@eargactivesemicolon<#1>#2;{\alt<#1>{\tikz@@command@path#2;}{\tikz@path@do@at@end}}
}
Although the code is not documented, you can see (specially the last line of the first code snippet), that \path
is made overlay-aware (in the beamer
sense) there, so basically anything that is a path (\node
, \draw
, \fill
, etc.) is overlay-aware.
As Sean Allred mentions in his comment
, it's also worth mentioning the aobs-tikz
package which defines auxiliary TikZ styles useful for overlaying picture elements in beamer
.
A simple example:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
\begin{document}
\begin{frame}
\tikz\draw[thick, alt=<2-4>{blue}{red}] (0,0) -- (1,1);
\end{frame}
\end{document}
Another interesting example of the use of this library can be found in my answer
to How can I make Beamer overlays with TikZ node attributes?.
-
3I would also add that you can
\usetikzlibrary{overlay-beamer-styles}
and use itsalt
key in styles, as in\tikz\draw[thick, alt=<2-4>{blue}{red}] (0,0) -- (1,1);
. More intexdoc aobs
. May 8, 2014 at 3:38 -
2@SeanAllred Yes, that's a useful addition. I've updated my answer incorporating your suggestion. Thanks. May 8, 2014 at 15:40