# reference on TikZ and Beamer overlay specifications

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?

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 de­fines aux­il­iary TikZ styles use­ful for over­lay­ing pic­ture 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?.

• I would also add that you can \usetikzlibrary{overlay-beamer-styles} and use its alt key in styles, as in \tikz\draw[thick, alt=<2-4>{blue}{red}] (0,0) -- (1,1);. More in texdoc aobs. May 8, 2014 at 3:38
• @SeanAllred Yes, that's a useful addition. I've updated my answer incorporating your suggestion. Thanks. May 8, 2014 at 15:40