O'Reilly logo

LaTeX Cookbook by Stefan Kottwitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a tree

A very common type of hierarchical graph is a tree. Tree nodes have children. These are connected by edges and are usually displayed in rows when growing down, or in columns when growing horizontally.

We will draw a tree presenting possible math formula layouts.

How to do it...

We will use basic TikZ, without any extra package. Follow these steps:

  1. Start with a document class:
    \documentclass{article}
  2. Load the tikz package:
    \usepackage{tikz}
  3. Start the document:
    \begin{document}
  4. Begin with a TikZ picture, and specify some options for it:
    \begin{tikzpicture}[sibling distance=10em,
      every node/.style = {shape=rectangle, rounded corners,
        draw, align=center,
        top color=white, bottom color=blue!20}]]
  5. Draw a node and add children to it:
     \node {Formulas} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required