TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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'm trying to draw AVL trees with TikZ, what I need is:

Binary tree with simple circle nodes, and adjustable height triangle (or rectangle) nodes for subtrees, both containing only single characters. Here's a picture:

enter image description here

I tried with rectangle and regular polygon, but they seem to be unaffected by aspect ratio... Is there an easy way of drawing something like this in TikZ?

share|improve this question
up vote 10 down vote accepted

Using the isosceles triangle shape and some manually set heights:




  inner/.style={circle,draw,minimum width=7mm,inner sep=0},
  leaf/.style={isosceles triangle,draw,shape border rotate=90,isosceles triangle stretches=true, minimum height=20mm,minimum width=12mm,inner sep=0,yshift={-20mm},font=\tiny},
  large leaf/.style={leaf,minimum height=35mm,yshift={-14.5mm}},
  level 1/.style={sibling distance=30mm},
  level 2/.style={sibling distance=21mm},
  level 3/.style={sibling distance=14mm},
  \node[inner] {T}
    [child anchor=north]
    child {node[inner] {L}
      child {node[large leaf] {}}
      child {node[inner] {LR}
        child{node[leaf] {}}
        child{node[leaf] {}}}}
    child {node[large leaf] {L.Allison}};



I don't know why the top vertices of the two large triangles are at different heights relative to their sibling nodes.

share|improve this answer
Thank you very much :) – tpv Dec 28 '10 at 18:06

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.