TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if anybody knows how to draw a multiway tree like in Knuth's The Art of Computer Programming, Volume 3 on page 484?

This looks like a rounded box with the value of the keys being rotated 90 degrees leftwards/counter clockwise and leaf nodes as little squares, with pointers to the next nodes halfway between keys.

Here is how it looks in print

share|improve this question
Thanks for adding the picture. – egreg Feb 5 '14 at 23:01
up vote 12 down vote accepted

A basic approach using TikZ:



  node distance=2cm and 1cm,
  mynoder/.style={draw,rounded corners},
\node[mynoder,text depth=0.4cm] (root) 
  {\quad$\cdots$\ \ \Rot{$031$}\qquad\Rot{$067$}\qquad\Rot{$097$}\ \ $\cdots$\quad\null};
\node[mynoder,below = of root.south west,anchor=west,text depth=0.8cm] (left) 
\node[mynoder,below = of root.south east,anchor=east,text depth=0.8cm] (right) 

\draw ([xshift=-10pt]root.center) -- (left);
\draw ([xshift=10pt]root.center) -- (right);
\foreach \Nodo in {left,right}
  \foreach \Corr in {-15,-5,5,15}
    \path ([yshift=-0.2cm,xshift=\Corr]\Nodo.center) -- ++(0,-1.5cm) node[mysq] (\Nodo\Corr) {};
    \draw ([yshift=-0.2cm,xshift=\Corr]\Nodo.center) -- (\Nodo\Corr);


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.