
假設我有一個 qtree:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree,tikz-qtree-compat}
\begin{document}
\begin{tikzpicture}
\tikzset{
% Define arrow style
pil/.style={
->,
thick,
shorten <=2pt,
shorten >=2pt,},
edge from parent/.style={draw, edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}},
level 1/.style={sibling distance=0.5cm}
}
\Tree
[.{1}
[.1-1 ]
[.1-2 ]
[.1-3
[.1-3-1 ]
[.1-3-2 ]
[.1-3-3 ]
[.1-3-4 ]
]
[.1-4 ]
[.1-5 ]
]
\end{tikzpicture}
\end{document}
是否可以將節點 1-2 和 1-4 移至更靠近 1-3 的位置?
是否可以讓 1-3 個子樹垂直生長,這樣我就可以得到這樣的結果:
我知道,它qtrees
可以垂直和水平增長。但是如何創建混合樹呢?
答案1
使用 plainTikZ
及其trees
庫,有一種可能性:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees,positioning}
\begin{document}
\begin{tikzpicture}[edge from parent fork down,node distance=0.5cm,sibling distance=1cm]
\node {1}
child {node {1-1}}
child {node {1-2}}
child {node (13) {1-3}}
child {node {1-4}}
child {node {1-5}}
;
\node [below = of 13, xshift=30pt] (131) {1-3-1};
\node [below = of 131] (132) {1-3-2};
\node [below = of 132] (133) {1-3-3};
\node [below = of 133] (134) {1-3-4};
\foreach \value in {1,...,4}
\draw (13.south) |- (13\value.west);
\end{tikzpicture}
\end{document}