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} ...

Get LaTeX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.