1

**

The Qrrbrbirlbel solution, together with samcarter_is_at_topanswers.xyz comment, are simpler and more up to date than the older solutions proposed, which require defining unnecessary styles.

**

Applying Qrrbrbirlbel comment, which answers my question, I used this modified code to draw the tikz tree.

The background rectangle appears on every slide. It is supposed to show only on slide 6, as the arrow. How can this be fixed!

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{trees,overlay-beamer-styles, arrows, backgrounds}
\begin{document}
\begin{frame}[t]
\frametitle{1}
\tikzset{
level 1/.style={level distance=10mm, sibling distance=6cm, violet},
level 2/.style={level distance=10mm, sibling distance=4cm, blue},
level 3/.style={level distance=14mm, sibling distance=2cm, green!60!black},
level 4/.style={level distance=14mm, sibling distance=2cm, cyan},
level 5/.style={level distance=16mm, sibling distance=2cm, magenta},
}
\begin{center}
\begin{tikzpicture} [->,>=stealth', scale=.8, transform shape, line width=.04cm, font=\small, inner sep=1mm]
%
\node[text=violet]
{root} 
%
child{node[text=red]{level1 columnA}}
%
child{node[text=blue]{level1 columnB}
  child [visible on=<2->]{node{level2 (columnB-2a)}
    child [visible on=<3->]{node[align=center]{level3 (columnB-2a3a)\\P}
      child [visible on=<4->]{node[align=center]{level4 (columnB-2a3a4a)}
        child [visible on=<5->]{node[align=center]{level5 (columnB-2a3a4a5a)}}
}}
}
%
  child [visible on=<2->]{node{level2 (columnB-2b)}
    child [visible on=<3->]{node[align=center]{level3 (columnB-2b3a)}
      child [visible on=<4->]{node[align=center]{level4 (columnB-2b3b4b)}
        child [visible on=<5->]{node[align=center]{level5 (columnB-2b3b4b5b)}}
}}
}
%
}
;%
\begin{scope}[on background layer]
\draw [visible on=<6->, line width=.04cm, blue, latex-latex] (-1.25,-7.5) -- ++(90:6cm) node [left, pos=0.5, text width=3cm, align=center] {hello};
\draw[visible on=<6->, draw=lime, fill=lime!60, line width=.08cm, rounded corners=4pt, opacity=.4] (-1,-.7) rectangle (7.6,-7.8);
\end{scope}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

enter image description here

This is slide number 1 (the rectangle should be invisible)

This is slide number 6 (the rectangle and arrow should be visible only here)

Hany
  • 4,709
  • 2
    Load the overlay-beamer-styles library from the aobs-tikz package and you can use things like visible on = <2-> as an option to a node. This site has plenty of examples. As a side note, do you really want to use the child syntax? The forest package and the graphdrawing library offers much better handling of tree diagrams. – Qrrbrbirlbel May 17 '23 at 07:30
  • @ Qrrbrbirlbel Thank you for your advice. – Hany May 17 '23 at 10:14
  • 1
    @Hany About your edit: try \draw[draw=lime, fill=lime!60, line width=.08cm, rounded corners=4pt, opacity=.4,visible on=<6->] (-1,-.7) rectangle (7.6,-7.8); If you set the colours afterwards, you overwrite the settings from visible on – samcarter_is_at_topanswers.xyz May 17 '23 at 12:38
  • @ samcarter_is_at_topanswers.xyz Thank you very much. It solved the problem. – Hany May 17 '23 at 12:44

0 Answers0