Published 2011-12-27 |
Author:
Frantisek Burian

Download as: [PDF] [TEX] • [Open in Overleaf]

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the
**LaTeX Forum**.

Oder frag auf Deutsch auf TeXwelt.de.
En français: TeXnique.fr.

```
% Author: Frantisek Burian
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
grow via three points={one child at (0.5,-0.7) and
two children at (0.5,-0.7) and (0.5,-1.4)},
edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
\node {texmf}
child { node {doc}}
child { node {fonts}}
child { node {source}}
child { node [selected] {tex}
child { node {generic}}
child { node [optional] {latex}}
child { node {plain}}
}
child [missing] {}
child [missing] {}
child [missing] {}
child { node {texdoc}};
\end{tikzpicture}
\end{document}
```

## Comments

Nice! But, I think you should make the boxes have the same size.

There’s a solution on TeX.stackexchange.com by Andrew Stacey (with a small, but, I think, important addition of mine), which works without dummy childs (this “[missing]” ones – where is the definition of them?), but is more difficult to understand, where to change the lengths (tip: look for “1cm”):

http://tex.stackexchange.com/questions/23647/drawing-a-directory-listing-a-la-the-tree-command-in-tikz/34268#34268

Hi Speravir,

thanks for the information! I will read Andrew's example.

Btw. [missing] is explained in the pgf/TikZ manual, 18. Making trees grow, 18.5.3 Missing Children.

Hi all!

The Stacey's example is much better (Maybe can be published there ?). But if i searched for it, i hasn't been found yet. This example is not as complex as Stacey's, but it is constructed with simple code.

Thanks.

Frantisek.

Hi Frantisek,

I like your example because it's easy to understand, and it shows how to use missing children. Andrew's defines a nice growth function, a clever approach, and I think I will add it too, just will have a look at it soon.

For anyone needing it, here's how you turn on arrows from parent-->child:

edge from parent path={[->] (\tikzparentnode.south) |- (\tikzchildnode.west)}]

I have a question concerning the aesthetics of this example. (It's a great example, by the way.)

Backgorund to my question: The line from "texmf" to "doc" is thicker than the line from "texmf" to "texdoc". I suppose that this happens because near the root of the tree many lines overlap.

My question: Is there any way to prevent this and thus to have the same line thicknes everywhere?

Thank you.

Adding comments is currently not enabled.