3

Suppose I want to add the list like structure instead of branches at the leaf node. How to do that for 'e', 'f', and 'g' and for 'h' and 'i' and for 'p' and 'q'? I want output like in the given image.

\documentclass[12pt,a4paper,openany,twoside]{report} % V changed from 12 point
\usepackage[graphicx]{realboxes}
\usepackage{adjustbox}


%%% For tikz picture
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}

\begin{document}

    \begin{figure}
\centering
\begin{adjustbox}{max size={\textwidth}{\textheight}}
\rotatebox{90}{ 
\begin{forest}
forked edges,
/tikz/>/.tip={Stealth[]},
my label/.style={%
tikz+={\node [font=\scriptsize, anchor=south east] at (.north east) {#1};}
},
for tree={%
draw,
align=center,
minimum height=20mm,
minimum width=30mm,
anchor=center,
%font=\scshape,
l sep'=10mm,
edge={->},
s sep'=10mm,
if n children=0{
tier=terminal
}{},
}
[a,
[b, l sep'=10mm
[c
[d,dashed,thick
[e] [f]
]
[g
[h,dashed,thick, s sep'=10mm]
[i,dashed,thick]
]
]
[j
[k,dashed,thick]
[l,dashed,thick]
]
]
[m, l sep'=20mm
[n, l sep'=20mm
[o,dashed,thick]
]
]
]
\end{forest}
}
\end{adjustbox}
\caption{caption} \label{fig:connect}
\end{figure}

\end{document}

enter image description here

2

2 Answers 2

2
\documentclass[tikz]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}
\forestset{
  declare boolean={my folder}{0},
  folder/.append style={ for descendants=my folder},
  folders down/.style={
    for tree={grow'=0, folder},
    tier=level me,
  },
}
\begin{document}

\begin{forest}
  forked edges,
  /tikz/>/.tip={Stealth[]},
  folder indent'=10mm,
  before typesetting nodes={where my folder={}{
    draw,
    align=center,
    minimum height=20mm,
    minimum width=30mm,
    anchor=center,
    %font=\scshape,
    l sep'=10mm,
    edge={->},
    s sep'=10mm,
    if n children=0{tier=level me}{},
    }}
  [a,
  [b
  [c
  [d,dashed,thick
  [e,   folders down  [f][g][h]] [f]
  ]
  [g
  [h,dashed,thick, folders down [h] [i] [] ]
  [i,dashed,thick]
  ]
  ]
  [j
  [k,dashed,thick, folders down [p] [q] ]
  [l,dashed,thick]
  ]
  ]
  [m, l sep'=20mm
  [n, l sep'=20mm
  [o,dashed,thick]
  ]
  ]
  ]
\end{forest}


\end{document}

tree

6

Maybe like this?

\documentclass[12pt,a4paper,openany,twoside]{report} % V changed from 12 point
\usepackage[graphicx]{realboxes}
\usepackage{adjustbox}
%%% For tikz picture
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta,positioning}
\newsavebox\treeA
\begin{document}
\savebox\treeA{\begin{forest}
for tree={grow'=0,folder}
[
 [e]
 [f]
 [g]
]
\end{forest}}

    \begin{figure}
\centering
\begin{adjustbox}{max size={\textwidth}{\textheight}}
\rotatebox{90}{ 
\begin{forest}
forked edges,
/tikz/>/.tip={Stealth[]},
my label/.style={%
tikz+={\node [font=\scriptsize, anchor=south east] at (.north east) {#1};}
},
for tree={%
draw,
align=center,
minimum height=20mm,
minimum width=30mm,
anchor=center,
%font=\scshape,
l sep'=10mm,
edge={->},
s sep'=10mm,
if n children=0{
tier=terminal
}{},
}
[a,
[b, l sep'=10mm
[c
[d,dashed,thick,alias=d
]
[g
[h,dashed,thick, s sep'=10mm]
[i,dashed,thick]
]
]
[j
[k,dashed,thick]
[l,dashed,thick]
]
]
[m, l sep'=20mm
[n, l sep'=20mm
[o,dashed,thick]
]
]
]
\node[anchor=north] at ([yshift=1em]d.south) {\usebox\treeA};
\end{forest}
}
\end{adjustbox}
\caption{caption} \label{fig:connect}
\end{figure}

\end{document}

enter image description here

3
  • Thanks. Can you make it flexible so that I can simply add as a child at any leaf node without worrying about their position like 'south', 'north', etc? Commented Jul 30, 2019 at 6:05
  • @ChandanGautam All you can do is to hope that cfr sees your question one day. All I would be able to do are marginal improvements.
    – user121799
    Commented Jul 30, 2019 at 8:39
  • Thanks. it seems it is not possible using the forest package in a simple way. SO, I have achieved the same by using some other package. Commented Jul 31, 2019 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .