I would like to draw a tree diagram consisting of circle nodes with three subparts divided by a t-line (see sample below). Instead of separating every tree node by hand I would like to only specify the style of the node accompanied by at least three parameters (the fields inside the circle node drawing). I already achieved the following by putting the following by putting this stackexchange circle node with t-lines example into a style:

  sectors/.style n args={5}{%
    minimum width=#4,
    append after command={
        \draw (\tikzlastnode.center) -- (\tikzlastnode.south) ;
        \draw (\tikzlastnode.west)   -- (\tikzlastnode.east) ;
        \path (\tikzlastnode.center) -- node[#5] {#1} (\tikzlastnode.north);  
        \path (\tikzlastnode.center) -- node[#5] {#2} (\tikzlastnode.south west); 
        \path (\tikzlastnode.center) -- node[#5] {#3} (\tikzlastnode.south east);

This works fine as long as there is only one root node. But as soon as I want to draw children nodes tikz fails to compile sayiong "Error: No shape named is known. [...]". So the following does not work.


      node [sectors={1}{2}{3}{1.5cm}{font=\bfseries}]{} 

I already noticed that there are problems with using tex macros within tree structures but I was not able to find a solution through the answers given there. I have not specified a simple tex-macro but a parameterized style. Maybe under the hood this works similar but I am not a pro when it comes to tikz and therefore was not able to adapt the solutions to this case.

Any help would be appreciated.

Here you see an outline of the tree structure I want to achieve: tree structure with circle nodes separated by t-lines

1 Answer 1


append after command uses a similar approach for saving the node’s name as the tree uses to connect the nodes. For this, I borrow most of the code from a label or a pin and apply it in your example, too. I am using edges here since with your \pgfextra example, you would also need the additional \pgfinterruptpath.

Unfortunately, both implementations do not inherit the style from the node. The path picture does this if I recall correctly but is very impractical in combination with transformations and you cannot use the node’s anchors.

For the best experience it would be best to implement this as a separate shape (at least the lines inside the circle).


  sectors/.style n args={5}{
    shape=circle, draw, minimum width={#4},
    append after command={%
        [current point is local = true]
        {[-,shorten >=+.5\pgflinewidth, shorten <=+.5\pgflinewidth]
          (\tikzlastnode.west)   edge (\tikzlastnode.east)
          (\tikzlastnode.center) edge (\tikzlastnode.south)
          [every edge/.style=]   edge node[#5] {#1} (\tikzlastnode.north)
                                 edge node[#5] {#2} (\tikzlastnode.south west)
                                 edge node[#5] {#3} (\tikzlastnode.south east)
  \node[sectors={0}{1}{1}{1.0cm}{}] {}%
      node [sectors={1}{2}{3}{1.0cm}{font=\bfseries}] {} 
  • Thanks! At least it is compiling now. But unfortunately the children nodes now overlap...
    – boris
    Commented Dec 7, 2013 at 22:22
  • @boris They should overlap eitherway. You need to adjust the sibling distance. Other packages like forest and tikz-qtree use TikZ but place the nodes in a way so that they not overlap. The trees of TikZ are very primitive in that way. Commented Dec 7, 2013 at 23:01
  • Unfortunately tikz seems to ignore the sibling distance directive. However I'll mark your answer as right then.
    – boris
    Commented Dec 7, 2013 at 23:16
  • 1
    @boris It works for me if given as an option to the TikZ picture, the path, a child or before the children, but not as a node option. Commented Dec 7, 2013 at 23:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .