我想在 TikZ 中创建一个类似的图形:
(节点的大小不是故意的,我试图让所有矩形的角都变圆)
这是我迄今为止的代码(MWE):
\documentclass{article}
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc}
\tikzstyle{rblock} = [rounded rectangle, draw, text width=1.4cm, text centered, minimum height=4em]
\begin{document}
\blindtext
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,transform shape,scale=0.8]
\node [rblock] (wibble) {wibble};
\coordinate [below=1cm of wibble] (c1);
\node [rblock,left=3cm of c1] (wobble) {wobble};
\node [rblock,right=3cm of c1] (wubble) {wubble};
\coordinate [below=1cm of wobble] (c2);
\node [rblock,left=0.2cm of c2] (foo) {foo};
\node [rblock,right=0.2cm of c2] (bar) {bar};
\node [rblock,below=0.3cm of wubble] (qux) {qux};
\node [rblock,left=0.2cm of qux] (baz) {baz};
\node [rblock,right=0.2cm of qux] (quux) {quux};
% TODO lines
\end{tikzpicture}
\end{center}
\end{document}
我自己也尝试过寻找解决方案,但我甚至不知道从哪里开始。我尝试寻找“分裂箭头”,但没有帮助。你能帮帮我吗?
所以我怎样才能在节点之间画出这些线?
还,我怎样才能让这些矩形更像我蹩脚的绘图上的矩形? 因此我希望角是圆的,但不要rounded rectangle
像形状.miscTikZ 库...
答案1
forest
包及其edges
库可能是一个选项:
\documentclass{article}
\usepackage{mwe}
\usepackage{forest}
\useforestlibrary{edges}
\begin{document}
\blindtext
\begin{center}
\begin{forest}
for tree={draw, rounded corners, minimum width=2cm, minimum height=4em},
forked edges,
[wibble
[Wobble
[Foo]
[Bar]]
[Wubble
[Baz]
[Qux]
[Quux]]]
\end{forest}
\end{center}
\end{document}