Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Imagine a simple tree:

\begin{tikzpicture}
    \node {Selbstregulation}
    [edge from parent fork down]
    child {node {Kognition}}
    child {node {Metakognition}
      child {node {Planung}}
      child {node {Monotoring}}
      child {node {Regulation}}
    }
\end{tikzpicture}

Is it possible to unveil the child nodes step by step using overlays in beamer? I tried with the \onslide command at several positions around child, but it doesn't work...

Any hints? - Thanks.

share|improve this question

4 Answers 4

A TikZ option to set the color to white depending on the current slide:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{trees}

\tikzset{hide on/.code={\only<#1>{\color{white}}}}

\begin{document}
\begin{frame}  
\begin{tikzpicture}
   \only<4>{} % Force beamer to show the correct amount of slides
    \node {Selbstregulation}
    [edge from parent fork down]
    child {node {Kognition}}
    child {node  {Metakognition}
      child [hide on=-2]  {node {Planung}}
      child [hide on=-3] {node {Monotoring}}
      child [hide on=1] {node {Regulation}}
    };
\end{tikzpicture}
\end{frame}
\end{document}

Placing the [hide on=..] option to get the right effect is a bit tricky. For example, the downward line is always drawn with the last child, so that node has to be uncovered first.

(Also note that the \tikzset has to be called outside the frames (I guess for reasons of catcode trickery).)

share|improve this answer
2  
Maybe it’s better to change the opacity to 0 instead of setting the color to withe, because the latter will keep visible on backgrounds with different colors (e.g. gradients or images). I didn’t test it so I’m not sure if it works … –  Tobi Mar 4 '12 at 13:01

I have been told this is not possible. The package author wrote in 2005 that it wasn't. If the ability has been added I do not know of it.

My correspondent's advice is the best workaround that I can think of:

To get the same effect, you may want to try drawing the final figure and then work backwards, making this invisible by making them have the same color as the background or transparent.

share|improve this answer
    
Thanks. To get it clear: you are suggesting that I should create the whole tree and copy-paste the picture on the preceding frames making the corresponding transparency changes? The problem here is that the connection lines beween the nodes remain visible, if set a node to be transparent... –  Fred Jun 13 '11 at 12:01
    
@Fred: To hide individual nodes, you can use {\only<2->{Planung}} for the node text. –  Caramdir Jun 13 '11 at 16:36

I improved the answer of Caramdir using opacity instead of color white, changing:

\tikzset{hide on/.code={\only<#1>{\color{white}}}}

with:

\tikzset{hide on/.code={\only<#1>{\color{fg!20}}}}

in my case I wanted a semitransparent effect, you can also set "fg!0" for full hiding, or any other level of opacity.

the full code is:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{trees}

\tikzset{hide on/.code={\only<#1>{\color{fg!20}}}}

\begin{document}
\begin{frame}  
\begin{tikzpicture}
   \only<4>{} % Force beamer to show the correct amount of slides
    \node {Selbstregulation}
    [edge from parent fork down]
    child {node {Kognition}}
    child {node  {Metakognition}
      child [hide on=-2]  {node {Planung}}
      child [hide on=-3] {node {Monotoring}}
      child [hide on=1] {node {Regulation}}
    };
\end{tikzpicture}
\end{frame}
\end{document}
share|improve this answer
    
This is a very similar approach to Mindmap tikzpicture in beamer (reveal step by step) :) –  Claudio Fiandrino Sep 7 '13 at 12:52

Well,

take a look at this solution of the problem:

http://old.nabble.com/successive-creation-of-tikz-mindmap-in-beamer-td22478489.html#a22522788

it seems to be not as easy as it should be, but doable...

share|improve this answer
    
Hi Norman, Welcome to TeX.sx! There's no need to sign off, as your user badge is automatically included in the lower right of your answer. In addition, please construct a minimal working example based on the advice you have linked to. Attribution is good, but answers should be self contained. –  qubyte Mar 4 '12 at 12:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.