\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path
\pagecolor{olive!50!yellow!50!white}
\begin{document}
\begin{tikzpicture}[level distance=1.25in,sibling distance=.25in,scale=.75]
\tikzset{edge from parent/.style=
{thick, draw,
edge from parent fork right},every tree node/.style={draw,minimum width=1in,text width=1in, align=center,fill=white},grow'=right}
\Tree
[. parent
[.{nice child0}
[.{grandchild0-0 } ]
[.{grandchild0-1 } ]
[.{grandchild0-2 } ]
[.{grandchild0-3 with a really long name } ]
]
[.child1
[.{grandchild1-0 } ]
[.{grandchild1-1 } ]
[.{grandchild1-2 } ]
]
[.child2 ]
[.child3 ]
]
\begin{scope}
\tikzset{edge from parent/.style=
{thick, draw,
edge from parent fork left},every tree node/.style={draw,minimum width=1in,text width=1in, align=center,fill=white},grow'=left}
\Tree
[.\node[draw=none]{};
[.{nice child0}
[.{grandchild0-0 } ]
[.{grandchild0-1 } ]
[.{grandchild0-2 } ]
[.{grandchild0-3 with a really long name } ]
]
[.child1
[.{grandchild1-0 } ]
[.{grandchild1-1 } ]
[.{grandchild1-2 } ]
]
[.child2 ]
[.child3 ]
]
\end{scope}
\end{tikzpicture}
\end{document}
答案1
这与您如何覆盖树节点有关。请注意,TikZ 绘制第一个节点并设置父节点,然后在其上方绘制;因此,按照您的方式,TikZ 会在标签上方填充绘制和空框。因此,切换绘制顺序可以解决问题。
参见 MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path
\pagecolor{olive!50!yellow!50!white}
\begin{document}
\begin{tikzpicture}[level distance=1.25in,sibling distance=.25in,scale=.75]
\tikzset{edge from parent/.style=
{thick, draw,
edge from parent fork right},every tree node/.style={draw,minimum width=1in,text width=1in, align=center,fill=white},grow'=right}
\Tree
[.{}
[.{nice child0}
[.{grandchild0-0 } ]
[.{grandchild0-1 } ]
[.{grandchild0-2 } ]
[.{grandchild0-3 with a really long name } ]
]
[.child1
[.{grandchild1-0 } ]
[.{grandchild1-1 } ]
[.{grandchild1-2 } ]
]
[.child2 ]
[.child3 ]
]
\begin{scope}
\tikzset{edge from parent/.style=
{thick, draw,
edge from parent fork left},every tree node/.style={draw,minimum width=1in,text width=1in, align=center,fill=white},grow'=left}
\Tree
[.{parent}
[.{nice child0}
[.{grandchild0-0 } ]
[.{grandchild0-1 } ]
[.{grandchild0-2 } ]
[.{grandchild0-3 with a really long name } ]
]
[.child1
[.{grandchild1-0 } ]
[.{grandchild1-1 } ]
[.{grandchild1-2 } ]
]
[.child2 ]
[.child3 ]
]
\end{scope}
\end{tikzpicture}
\end{document}