How to make a 3 level deep tree with tikz

You could specify options for each level, for instance silbling distance but also level distance.

Example:

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm,
  level 1/.style={sibling distance=3cm},
  level 2/.style={sibling distance=1.5cm}]
  \node {root}
    child {node {left}
      child {node {lleft}}
      child {node {rleft}}
    }
    child {node {right}
    child {node {lright}}
      child {node {rright}}
    };
\end{tikzpicture}
\end{document}

Output:

alt text


tikz-qtree is an awesome package for more convenient tree drawing in tikz.


I suppose forest deserves to be mentioned as well.

Code

\documentclass[border=2pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={l+=1cm} % increase level distance
  [root
    [left[lleft][lright]]
    [right[rleft][rright]]
  ]
\end{forest}
\end{document}

Output

enter image description here

Tags:

Trees

Tikz Pgf