假设我有一个 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}