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.

3
  • The tikz package is what I would recommend. Apr 16, 2012 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? Apr 16, 2012 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 (inkscape.org) of geogebra (geogebra.org/cms).
    – user11232
    Apr 16, 2012 at 23:23

1 Answer 1

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

4
  • Thank you! It looks like Tikz is certainly a reasonable solution. I will look into it. Apr 18, 2012 at 0:32
  • @JonathanGallagher: you're welcome! If my response answers your question, please consider marking it as "Accepted" by clicking the tickmark below its vote count. Apr 18, 2012 at 1:28
  • Do you know of documentation for tikz where things like apex are defined. I did not see it in the manual by Tantau for example. Apr 18, 2012 at 17:44
  • @JonathanGallagher: the anchors for the isosceles triangle shape appear in a diagram in page 429 of the current CTAN version of the pgfmanual. Apr 18, 2012 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .