With minimal tikz knowledge, I try to create a node like shape, which has two filled circles in it. Here is my attempt, which suffers from these problems:

  • The appended path components seem to be covered by the main node.
  • Options passed to later path components are ignored.


  rectangle split,
  rectangle split parts=3,
  rectangle split horizontal=true,
    append after command={%
      coordinate (#1 one) at ($ (#1.east)!1/6!(#1.west)  $)
      coordinate (#1 two) at ($ (#1.east)!5/6!(#1.west)  $)
     [fill=red] (#1 one) circle (2pt)
     [fill=red] (#1 two) circle (2pt)

\node[cell=a,label=left:{missing circles}] at (0,-1) {};
\node[cell=b,above=1ex of a,label=left:{circles show, but not red}]  {} [draw];
\node[cell=c, above=1ex of b,label=left:{circle ignore style options}] {}  [fill=green];
\node[cell=d, above=1ex of c,label=left:{node hides circles},fill=blue!20] {}  [fill=green];

The output of the above code


This isn't a good way to define a new shape. Best is to define a proper new shape with \pgfdeclareshape. You can inherit various properties from a known shape. An alternative is to use the new (PGF-CVS) pic which is a simpler form of a shape and can be built from high-level TikZ commands rather than low-level PGF commands.

To illustrate this advice, let's examine why your code is producing what it does in each case. The keys are: order of drawing, and scoping. In particular:

  1. When a path has paths and nodes, the paths are rendered first and the nodes afterwards. Note that this is purely about rendering. They are computed as they occur on the path. It is just that the nodes are shipped off into a box which is put on top of the other path components.

  2. The stuff in the append after command is executed inside a group.

  3. Paths are treated uniformly with regard to drawing and filling. In particular, either all components are filled or none are filled, and all use the same colour. The actions and colours in place at the end of the path construction are those that will be used.

  4. Node paths are separate to the rest of the path and can be separately styled. The stuff in append after command is not part of the node, though, but part of the main path.


  1. "Missing circles". The [fill=red] occurs inside a group and so isn't visible at the end of the path construction. It therefore has no effect. Even putting a fill command outside the group still means that the fill colour is not red as that is only set inside the group.

  2. "Show, but not red". As above, [fill=red] has no effect. But the [draw] sets the action to draw so they are drawn. As no colour is in effect, the default colour (black) is used.

  3. "Ignore style options". Same as the previous two. The [fill=green] is the only specification in effect by the end of the path.

  4. "Node hide circles". This is because nodes are rendered after the path, so they go on top.

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.