6

I want to be able to draw something like nested triangles that are arranged in a tree-like fashion. Or explicitly, a node of a tree is represented as an isosceles triangle pointed upward. Each subtree should be drawn as a subtriangle.

Here is an image

enter image description here

Are there any nice packages for doing things like this? Or should I use a geometry drawing package.

egreg
  • 1,121,712
  • The tikz package is what I would recommend. – Peter Grill Apr 16 '12 at 20:52
  • Thank you, I added an image.

    I was discussing Tikz with a few people this morning, and I had gotten the impression that is not user friendly. Would you suggest that in fact, Tikz is easy to use?

    – Jonathan Gallagher Apr 16 '12 at 21:16
  • Tikz will have hiccups in the beginning. But you know it will be a starting trouble which goes off slowly. If you are after drawing software you can look at inkscape (http://inkscape.org/) of geogebra (http://www.geogebra.org/cms/). –  Apr 16 '12 at 23:23

1 Answers1

6

As others have commented, PGF/TikZ can be an option. In the following example I used the isosceles triangle shape from the shapes library and defined the \MyTr command with three mandatory arguments (name, minimum height, and position of the triangle). Of course, this is just to show one possibility, but you can change and adapt the code depending on your specific needs:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}

\definecolor{tblue}{RGB}{207,232,229}

\newcommand\MyTr[3]{%
  \node[isosceles triangle, isosceles triangle apex angle=70,
    draw, inner sep=0pt,anchor=lower side,rotate=90,draw=black,
    fill=tblue, minimum height=#2 cm] (#1) at #3 {};
  \fill (#1.apex) -- (#1.20) -- (#1.340) -- cycle;}

\begin{document}

\begin{tikzpicture}
\MyTr{a}{8}{(0,0)}
\MyTr{b}{2.5}{(-2.5,0)}
\MyTr{c}{2.5}{(2.5,0)}
\end{tikzpicture}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128