I try to draw parts of a split rectangle in a dashed or dotted style. Thus I want the following code

\node[draw,rectangle split,rectangle split parts=2,rectangle split horizontal]
  {foo \nodepart[text width=2cm]{second} bar};

to produce an image like this:

enter image description here

The dashed/dotted part should look uniform, i.e., the different lengths of the dashes in the picture are a result of my bad paint skills ;-)

I also would like to use the same effect for a vertical split rectangle. Any ideas?


Draw the whole border after the node is built:


\usetikzlibrary{shapes.multipart, calc}



\node[rectangle split,rectangle split parts=2, rectangle split horizontal,
    append after command={\pgfextra
        \draw ($(othername.one split south)!.25!(othername.south east)$)-|(othername.west)|-($(othername.one split north)!.25!(othername.north east)$);
        \draw ($(othername.one split south)!.75!(othername.south east)$)-|(othername.east)|-($(othername.one split north)!.75!(othername.north east)$);
        \draw[dashed] ($(othername.one split south)!.25!(othername.south east)$)--($(othername.one split south)!.75!(othername.south east)$);
        \draw[dashed] ($(othername.one split north)!.25!(othername.north east)$)--($(othername.one split north)!.75!(othername.north east)$);
        \draw (othername.one split north)--(othername.one split south);
    \endpgfextra} ]
  {foo \nodepart[text width=2cm, draw=none]{second} bar};


enter image description here

  • I like how clean this solution is and also how extensible. Thanks for letting me know! – Max Maier Jul 22 at 19:33

Try overdraw the second part of multi part node with white dashed line:

\documentclass[tikz, margin=3mm]{standalone}

node distance = 0pt,
  mpnh/.style = {% multi part node horisontal
        rectangle split, rectangle split parts=2,
        rectangle split horizontal, 
        draw, outer sep=0pt, align=center}
\node (mpnh) [mpnh]
    \nodepart[text width=2cm]{second} bar};
\draw[white, semithick, dashed] (mpnh.two north)+(-0.5,0) -- ++ (.5,0)
                                (mpnh.two south)+(-0.5,0) -- ++ (.5,0);

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.