i want to create a node in TikZ that consists of two parts. So far I have tried the following


\tikzstyle{splitbox} = [rectangle split, rectangle split parts=2, minimum width=3cm, minimum height=2cm, text centered, text width=3cm, draw=black, rectangle split part fill={white, lightgray}]


\begin{tikzpicture}[node distance=4cm]
\node (node) [splitbox] {\nodepart{one} The whole thing
\nodepart{two} A part of it}; 

This gives me a result that looks like

Image 1

So far so good. But actually i want it to look more like

Image 2

Does anyone have an Idea, how I can achive that? Have been googeling for hours. The "part" nodepart should always be, where my arrow starts. Thanks a lot for your suggestions!

3 Answers 3


An alternative solution:


    node distance=0mm, 
every node/.style = {rectangle, inner sep=0mm, outer sep=0mm,
                     align=center, minimum height=15mm},  
\node (t) [text width=5cm] {The whole thing};
\node (b) [text width=3cm,draw,fill=lightgray, 
           below=of t] {A part of it};
\node [draw,fit=(t) (b)]    {};
  • Thank you very much! I have to say, that i like this one even a little better as the other suggestion, as I can connect it with my tikzstyles in the preamble... Mar 9, 2016 at 16:28

like this :


\usetikzlibrary{shapes, positioning}


\begin{tikzpicture}[node distance=4cm]
\node [name=n1, rectangle, minimum width=5cm, minimum height=3cm,
text centered, text width=3cm, draw=black] {};

\node [name=t, rectangle, minimum width=5cm, minimum height=1.5cm,
text centered, text width=3cm, below=(0mm of n1.north)] {The whole thing};

\node [name=n2,rectangle, minimum width=3cm, minimum height=1.5cm,
text centered, text width=3cm, anchor=south, above=(0cm of n1.south),
draw=black,fill=lightgray] {A part of it};


enter image description here

  • Thank you very much!!! This works and the output looks exactly how I want it to be. Nevertheless it produces two error messages: Package PGF Math Error: Unknown operator o' or of' (in '(0cm of n1.south)'). draw=black,fill=lightgray] (followed by: {A part of it};) Package PGF Math Error: Unknown operator o' or of' (in '(0mm of n1.north)'). ... text width=3cm, below=(0mm of n1.north)] (followed by: {The whole thing};) Mar 9, 2016 at 15:31
  • you need positionings : \usetikzlibrary{shapes, positioning}
    – flav
    Mar 9, 2016 at 15:47
  • That helped! My mistake ;) Thank you very much! Mar 9, 2016 at 15:52

Another alternative with a unique node defined as a matrix and matrix of nodes:

    part/.style={draw, fill=black!30},
        matrix of nodes,
        inner xsep=3mm,
        inner ysep=-.5\pgflinewidth,
        nodes={minimum height=12mm},
        row 2/.style={nodes={part}}

\node[whole] (A) {
The whole thing\\
A part of it\\

enter image description here

  • you can use it on a \node[whole] if you add matrix to the style
    – percusse
    Mar 10, 2016 at 9:13
  • 1
    @percusse I tested it before posting my answer and it didn't worked. Now it did. How are you controlling my computer? ;-)
    – Ignasi
    Mar 10, 2016 at 9:46
  • With a mouse obviously; something emacs, vim geeks would never suspect :P
    – percusse
    Mar 10, 2016 at 9:59

You must log in to answer this question.

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