\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node {One}[edge from parent fork right, grow'=right, align=right]
child { node(yongnian) {1}
child {node(xixiang){11}
child {node{111}
child {node{111}
child {node{111}}}}
}
child {node(xihui)[below of=xixiang]{222}}
child {node(xifu)[below of=xihui]{222}}
child {node(xilu)[below of=xifu]{222}}
}
child { node(qingnian)[below of=yongnian] {2}
child {node{Me}}
child {node{My}}
}
child { node (shengnian)[below of=qingnian] {3}
child {node{Josh}}
child {node{arah}}
}
child { node(fengnian)[below of=shengnian] {4}
child {node{sh}}
child {node{arah}}
}
;
\end{tikzpicture}
\end{document}
答案1
添加适当的sibling distance
距离
level 1/.style={sibling distance=1in},
level 2/.style={sibling distance=1cm},
此外,您不需要below of=
这里的所有这些东西。作为库的附注,positioning
它应该是below = of
。
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
level 1/.style={sibling distance=1in},
level 2/.style={sibling distance=1cm},
grow'=right, align=right
]
\node {One}[edge from parent fork right]
child { node(yongnian) {1}
child {node(xixiang){11}
child {node{111}
child {node{111}
child {node{111}}}}
}
child {node(xihui){222}}
child {node(xifu){222}}
child {node(xilu){222}}
}
child { node(qingnian) {2}
child {node{Me}}
child {node{My}}
}
child { node (shengnian) {3}
child {node{Josh}}
child {node{arah}}
}
child { node(fengnian) {4}
child {node{sh}}
child {node{arah}}
}
;
\end{tikzpicture}
\end{document}