组织结构图:如何使用森林在底部添加组合条目?

组织结构图:如何使用森林在底部添加组合条目?

我正在尝试在组织结构图中添加如图所示的组合条目。提前谢谢您。在此处输入图片描述

\documentclass[border=20pt,tikz]{standalone}
\usepackage[edges]{forest}

\forestset{
  direction switch/.style={
    for tree={edge+=thick, font=\sffamily},
    where level>=2{folder, grow'=0}{for children=forked edge},
    where level=4{}{draw},
  },
}
\begin{document}

\begin{forest}
  % forest preamble: determine layout and format of tree
  direction switch,
  [a - general chamber
   [b - chamber
    [c - chamber
      [d - chamber
                [ (e - chamber)]
        ]
    ]
    [f - chamber
      [g - chamber
                [h - chamber]
                [i - chamber]
      ]
      [j - chamber
      ]
    ]
   ]
  [k - chamber
    [l - chamber
      [m - chamber
      [n - chamber
      ]
      ]
      [o - chamber
      ]
   ]
 ]    
 ]
\end{forest}
\end{document}

答案1

请注意,如果您在某处找到了您发布的代码,请注意您应该注明其归属(最好带有链接,但至少带有作者)。

forest无法这样做,因为节点只能有一个父节点。但是,您可以使用包的设备来伪造它。由于您还需要为单个节点改变另一个生长方向node,因此最简单的方法是伪造整个节点。

\documentclass[border=20pt,tikz]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{calc}

\forestset{
  direction switch/.style={
    for tree={edge+=thick, font=\sffamily},
    where level>=2{folder, grow'=0}{for children=forked edge},
    where level=4{}{draw},
  },
}
\begin{document}

\begin{forest}
  % forest preamble: determine layout and format of tree
  direction switch,
  [a - general chamber
   [b - chamber
    [c - chamber
      [d - chamber
                [ (e - chamber)]
        ]
    ]
    [f - chamber
      [g - chamber
                [h - chamber]
                [i - chamber]
      ]
      [j - chamber, tikz+={\node [draw, anchor=north] (extra) at ([yshift=-20pt]!c.south -| {$(!c)!.5!(ochamber)$}) {ABC};
        \draw [thick] (!c) -- ++(0pt,-15pt) coordinate (a) -| (extra.north) (ochamber.south) -- (ochamber.south |- a) -| (extra.north);
      }
      ]
    ]
   ]
  [k - chamber
    [l - chamber
      [m - chamber
      [n - chamber
      ]
      ]
      [o - chamber, name=ochamber
      ]
   ]
 ]    
 ]
\end{forest}
\end{document}

具有“假”双父节点的树

相关内容