1

In the example the fourth child node is crossed by the line, but the others, e. g. the second one not. How can I achieve that also for the fourth one the line is "lying under" the box?

\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}
  • Could you add an image of the current output, please? – Anakhand Jan 29 '19 at 11:13
2

With code from 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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.