# show part of tikzpicture

Is it possible to extract a part of a tikzpicture?

See for example this tikzpicture. I would like to show the parts with different colors on different slides. (The real picture is more complex, wide and cant be divided in different tikzpictures.)

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw[fill=green] (0.0, 0.0) rectangle (3.0, 2.0);
\draw[fill=blue]  (3.0, 0.0) rectangle (6.0, 2.0);
\draw[fill=red]   (6.0, 0.0) rectangle (9.0, 2.0);
\end{tikzpicture}
\end{frame}
\end{document}


If its also possible to animate the views (from left to right) like you have a window for the current view and drag it to the next part of the picture I would like to see a solution for that, too.

Update: I just found the \clip-Command. By this I get a copy paste solution: Three slides with the code above and additional commands

\clip (0.0, 0.0) rectangle (3.0, 2.0);
\clip (3.0, 0.0) rectangle (6.0, 2.0);
\clip (6.0, 0.0) rectangle (9.0, 2.0);

• Have a look at Highlighting specific parts of a TikZ drawing which might be want you are looking for. – Martin Scharrer Jun 24 '13 at 14:58
• In the real picture there are elements that cover more than one area. Thus I think I cant use the solution in that topic (though I dont understand every detail of it). – user25233 Jun 24 '13 at 15:22
• For the motion between two frames you might want to use \transpush[direction=180,duration=X] where X is the number of seconds you want for your transition. This line has to be inserted between the \begin{frame} and the \end{frame} commands. – Ludovic C. Jun 24 '13 at 15:33
• I don't see the problem with elements that cover more than one area. Actually your question isn't very clear to me. Are you trying to highlight or extract parts of your diagram? Both things are completly different to me. Please have only one problem per question. – Martin Scharrer Jun 24 '13 at 15:34
• I wanted to show just a part of my picture and already found a solution myself (-> '\clip'-command). I guess the other part is impossible anyway.. and I take the '\transpush'-command for it. – user25233 Jun 24 '13 at 15:51

Maybe \onslide is what you are looking for:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{lmodern}%

\begin{document}
\begin{frame}
\frametitle{A title}
\begin{tikzpicture}
\onslide<1>{\draw[fill=green] (0.0, 0.0) rectangle (3.0, 2.0);}
\onslide<2>{\draw[fill=blue]  (3.0, 0.0) rectangle (6.0, 2.0);}
\onslide<3>{\draw[fill=red]   (6.0, 0.0) rectangle (9.0, 2.0);}
\end{tikzpicture}
\end{frame}
\end{document}

• TikZ commands are overlay aware so you can also use \draw<1->... etc. – percusse Jun 25 '13 at 11:19
• @percusse Yes, but no. The use of \draw<1>, \draw<2> and \draw<3> will place all rectangles at the same place (like \only would do). With <1->, <2-> and <3-> you won’t notice the difference unless you need a TikZ picture that stays the same size on every slide. – Qrrbrbirlbel Jun 25 '13 at 14:01
• @Qrrbrbirlbel Ah I forgot.For that you can use the overlay environment instead. Beamer will still scan the frame so the BB size will be consistent among slides. There should be a question specifically for that. – percusse Jun 25 '13 at 14:39