2

I have a slide with some text and I want to add a tree under them.

something like the gif below. enter image description here

The pause for each node is really not important but if possible, it will be much better. and is there possible to change forest size?

I tried this code but tree exceed the page size:

\documentclass{beamer}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\usepackage{lipsum}

\begin{document} \begin{frame}[fragile]{Introduction} \begin{itemize} \setlength\itemsep{1em} \item \lipsum[1][1-5] \item \lipsum[1][1-5] \end{itemize} \begin{figure} \begin{forest} for tree = { circle, draw, edge = {-Straight Barb, semithick}, l sep=8mm, s sep=15mm, minimum size = 3em, EL/.style 2 args = {edge label={% node[midway, font=\footnotesize, align=center, inner sep=2pt, anchor=south #1]{#2}}, }, } [Outlook, [Humidity, EL={east}{sunny} [Play, EL={east}{H $\leq$ 75}] [Don't play, EL={west}{H > 75}] ] [Play, EL={east}{Overcast}] [Wind, EL={west}{Raining} [Play, EL={east}{weak}] [Don't play, EL={west}{strong}] ] ] \end{forest} \end{figure} \end{frame} \end{document}

  • 1
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for the users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – samcarter_is_at_topanswers.xyz Dec 03 '23 at 11:20
  • 1
    Have a look at the overlay-beamer-styles tikz library to uncover nodes step-by-step – samcarter_is_at_topanswers.xyz Dec 03 '23 at 11:21
  • Can you clarify what problem you face in adding the tree? From your previous question https://tex.stackexchange.com/q/702890/36296 it seems like you know how to draw basic trees. What exactly is missing to reproduce the one shown in your image? – samcarter_is_at_topanswers.xyz Dec 03 '23 at 14:01
  • I'd suggest this question as base concept, except for the time constraint. – FHZ Dec 03 '23 at 14:05
  • @samcarter_is_at_topanswers.xyz I want to draw this tree in beamer and if it's possible add puase for each node otherwise resize the tree to fit it in my slide, like the gif I provide in question. – Erfan Riahi Dec 03 '23 at 14:17
  • @ErfanRiahi Please show what you tried. If you can draw the tree, we can help you resize it and adding pauses. – samcarter_is_at_topanswers.xyz Dec 03 '23 at 14:24
  • @samcarter_is_at_topanswers.xyz I edit the question and add the code. as you can see tree exceed the page. In addition I really like to make all node size the same, how to do that? minimum size doesn't work. – Erfan Riahi Dec 03 '23 at 15:04
  • @ErfanRiahi, as a bypass, what you always can do is to make several copies of the >>page<<, delete from the tree backwards so to say and show page after page. This gives the same visual impression. – MS-SPO Dec 03 '23 at 15:20
  • Possible duplicate of https://tex.stackexchange.com/questions/169127/scale-of-a-forest-tree and https://tex.stackexchange.com/a/112471/36296 – samcarter_is_at_topanswers.xyz Dec 03 '23 at 15:54
  • 2
    But don't put your tree in a scalebox as the top ranking answer to the earlier question does. The lower ranked answer is much better. Alternatively, look at options for tikz scaling. – cfr Dec 03 '23 at 23:28

1 Answers1

7
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{lipsum}

\forestset{ visible on/.style={ for tree={ /tikz/visible on={#1}, edge+={/tikz/visible on={#1}}}}}

\begin{document} \begin{frame}[fragile] \frametitle{Introduction} \begin{itemize} \setlength\itemsep{1em} \item \lipsum[1][1-5] \item \lipsum[1][1-5] \end{itemize} \begin{figure} \scriptsize \begin{forest} for tree = { ellipse, draw, edge = {-Straight Barb, semithick}, l sep=1.5em, s sep=2.5em, minimum width=6em, EL/.style 2 args = {edge label={% node[midway, font=\tiny, align=center, inner sep=2pt, anchor=south #1]{#2}}, }, } [Outlook [Humidity, visible on=<2->, EL={east}{sunny} [Play, visible on=<3->, visible on=<3->, EL={east}{H $\leq$ 75}] [Don't play, visible on=<4->, EL={west}{H > 75}] ] [Play, visible on=<5->, EL={east}{Overcast}] [Wind, visible on=<6->, EL={west}{Raining} [Play, visible on=<7->, EL={east}{weak}] [Don't play, visible on=<8->, EL={west}{strong}] ] ] \end{forest} \end{figure} \end{frame} \end{document}

enter image description here