[Tex/LaTex] How to add multi-line text below a node in a tree in forest

foresttext manipulationtrees

I want to make a tree which has bulleted lists centered below the child nodes, like so:

tree image I want

I've searched on TeX SE and found questions which describe putting labels below nodes, but it doesn't quite work out for multiline text or lists. This is my MWE (it generates the pdf in TexStudio even though I get some residual errors):

\documentclass[11pt, letterpaper,twoside, fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{forest}

\begin{document}
    \begin{figure}
        \begin{center}
            \begin{forest}
                for tree={
                    myleaf/.style={label=below:{\strut#1}},
                    s sep=5cm
                }
                [Root Question,rectangle,rounded corners,draw
                    [Yes,rectangle,rounded corners,draw,align=center,
                        myleaf={$\bullet$ Subsequent question?\\
                                $\bullet$ Subsequent longer\\
                                    question?}
                    ]
                    [No,rectangle,rounded corners,draw]
                ]
                \node[above=30pt,align=center,anchor=center] {Tree Title};
            \end{forest}
        \end{center}
        \label{fig_tree1}
    \end{figure}    
\end{document}

current bad mwe tree

I'm very new to Latex trees and I've been using forest so far, but I'm not opposed to a TikZ solution.


On an unrelated note, I would eventually also like to place two trees side-by-side in a single figure (as shown below, but with the "subsequent question" text slightly bigger). I could use some guidance on that too.

two trees side by side

Best Answer

You need to say align=left or something along these lines in order to allow for multi-line texts in a node. (A label is a node, too.)

\documentclass[11pt, letterpaper,twoside, fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{forest}

\begin{document}
    \begin{figure}
        \begin{center}
            \begin{forest}
                for tree={
                    myleaf/.style={label={[align=left]below:{\strut#1}}},
                    s sep=5cm
                }
                [Root Question,rectangle,rounded corners,draw
                    [Yes,rectangle,rounded corners,draw,align=center,
                        myleaf={$\bullet$ Subsequent question?\\
                                $\bullet$ Subsequent longer\\
                                    question?}
                    ]
                    [No,rectangle,rounded corners,draw]
                ]
                \node[above=30pt,align=center,anchor=center] {Tree Title};
            \end{forest}
        \end{center}
        \label{fig_tree1}
    \end{figure}    
\end{document}

enter image description here

You could also use itemize if you specify the text width. This also addresses your second question, too.

\documentclass[11pt, letterpaper,twoside, fleqn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{subcaption}
\usepackage{floatrow}
\usepackage{forest}
\usetikzlibrary{positioning}
\tikzset{leaflet/.style={align=left,text width=3.14cm}}
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=t, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{forest}
                for tree={
                    s sep=3.14cm
                }
                [Root Question,rectangle,rounded corners,draw,alias=root
                    [Yes,rectangle,rounded corners,draw,alias=LL]
                    [No,rectangle,rounded corners,draw,alias=LR]
                ]
                \node[above=12pt of root,align=center,anchor=center] {LeftTree Title};
                \node[below=1pt of LL,leaflet]
                {\begin{itemize}\setlength\itemsep{0pt}
                                \item Subsequent question?
                                \item Subsequent longer
                                    question?
                                \end{itemize}};
                \node[below=1pt of LR,leaflet]
                {\begin{itemize}\setlength\itemsep{0pt}
                                \item Subsequent question?
                                \item Subsequent longer
                                    question?
                                \end{itemize}};                             
            \end{forest}}{\caption{Left.\label{fig:left}}}
\ffigbox{\begin{forest}
                for tree={
                    s sep=3.14cm
                }
                [Root Question,rectangle,rounded corners,draw,alias=root
                    [Yes,rectangle,rounded corners,draw,alias=RL]
                    [No,rectangle,rounded corners,draw,alias=RR]
                ]
                \node[above=12pt of root,align=center,anchor=center] {Right Tree Title};
                \node[below=1pt of RL,leaflet]
                {\begin{itemize}\setlength\itemsep{0pt}
                                \item Subsequent question?
                                \item Subsequent longer
                                    question?
                                \end{itemize}};
                \node[below=1pt of RR,leaflet]
                {\begin{itemize}\setlength\itemsep{0pt}
                                \item[{}] Hibernate?
                                \end{itemize}};                             
            \end{forest}}{\caption{Right.\label{fig:right}}}
\end{subfloatrow}}
{\caption{Trees.}\label{fig:Trees}}
\end{figure}
\end{document}

enter image description here

As you can see, things are now doubled: there is a title and a caption. I kept both as it may be easier to drop one of those than to add one.

Related Question