如何在森林包的叶节点创建列表?

如何在森林包的叶节点创建列表?

假设我想在叶节点添加类似列表的结构而不是分支。如何对“e”、“f”和“g”以及“h”和“i”以及“p”和“q”执行此操作?我想要像给定图像中那样的输出。

\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}

在此处输入图片描述

答案1

\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}

树

答案2

可能像这样吗?

\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}

在此处输入图片描述

相关内容