2

I am creating a tree in which the edges from a child to its children are dashed. I got this using child[dashed]. Now all the edges of these children are dashed.

I want to override this. So unable to find this command, I tried child[normal] and child[solid] in its children; both did not work. Also child[thick] and child[thin] does not changed the dashed nature.

Please can anyone tell me the correct command to be used.

mri
  • 135
  • 6

2 Answers2

5

From manual for Tikz (pp 323):

\begin{tikzpicture}
[edge from parent/.style={draw,red,thick}]
\node {root}
child {node {left} edge from parent[dashed]}
child {node {right}
child {node {child}}
child {node {child} edge from parent[draw=none]}
};
\end{tikzpicture}

follows, that you can define style of each edge in tree. To be more specific, you should provide a MWE, which show your problem.

Zarko
  • 296,517
  • set edge from parent[dashed] will make all edges below this child dashed. The example from the manual applies to a child without further children. I want to switch off dashed for all children; so, only one dashed edge (and it's not to a leave). – Tom Verhoeff Oct 22 '21 at 18:55
  • My comment was really more meant to draw attention to a limitation in the example from the manual. My "question" is already answered here. – Tom Verhoeff Oct 24 '21 at 12:16
  • You quoted the example from the manual. Unfortunately, that example is too limited to help the OP. – Tom Verhoeff Oct 26 '21 at 06:54
5

If you use forest you can specify this once for the relevant parent and still limit the effect to its immediate children. In addition, specifying a tree involves less typing ;).

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={
  },
  [root, for children={edge=dashed}
    [child 1
      [grandchild 1]
      [grandchild 2]
    ]
    [child 2
      [grandchild 3]
      [grandchild 4]
    ]
  ]
\end{forest}
\end{document}

dashed children and unblemished grandchildren

cfr
  • 198,882