在该示例中,第四个子节点与线相交,但其他节点(例如第二个节点)没有。我如何才能使第四个子节点的线也“位于”框下方?
\documentclass{article}
\usepackage{geometry}
\geometry{textwidth=126mm, textheight=192mm}
\usepackage{color}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=7em,
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=blue!20}]
\node {Top}
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} };
\end{tikzpicture}
\end{document}
答案1
使用来自的代码https://tex.stackexchange.com/a/20426/2388:
\documentclass{article}
\usepackage{geometry}
\geometry{textwidth=126mm, textheight=192mm}
\usepackage{color}
\usepackage{tikz}
\pgfdeclarelayer{back}
\pgfsetlayers{back,main}
\makeatletter
\pgfkeys{%
/tikz/on layer/.code={
\pgfonlayer{#1}\begingroup
\aftergroup\endpgfonlayer
\aftergroup\endgroup
},
}
\makeatother
\begin{document}
\begin{tikzpicture}[sibling distance=7em,
edge from parent/.style={draw,on layer=back},
every node/.style = {shape=rectangle, rounded corners,
draw, align=center,
top color=white, bottom color=blue!20}]
\node {Top}
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} }
child { node {A\\B\\C\\D} };
\end{tikzpicture}
\end{document}