5

Possible Duplicate:
Drawing a directory listing a la the tree command in TikZ

Is there a way to configure the trees drawn by TikZ to have child nodes at the same level listed below each other? Basically, I want something similar to the output of the tree command in a Command Prompt.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\section*{TikZ tree}
\begin{tikzpicture}
\node {toplevel} 
    child { node {Foo}
            child { node {foo} }
            child { node {bar} }
            child { node {baz} }
    }
    child { node {Bar}
        child { node {foo} }
        child { node {bar} }
        child { node {baz} }
    }
    child { node {Baz}
        child { node {foo} }
        child { node {bar} }
        child { node {baz} }
    };
\end{tikzpicture}

\section*{Desired tree structure}
\begin{verbatim}
toplevel
|-- Foo
|   |-- foo
|   |-- bar
|   `-- baz
|-- Bar
|   |-- foo
|   |-- bar
|   `-- baz
`-- Baz
    |-- foo
    |-- bar
    `-- baz
\end{verbatim}

\end{document}
  • There's been a very similar question that got a partial answer: tex.stackexchange.com/questions/23647/… – Jake Nov 9 '11 at 10:47
  • Although the other one didn't get a full answer, this does feel like any answer to this would work for that and vice versa, so I'm tempted to vote to close as a duplicate and stick a flashing neon comment saying: "This is still unsolved" somewhere prominent. – Loop Space Nov 9 '11 at 10:58
  • On the question itself (it's quite likely that I didn't see the original one), does it have to be done via a tree? It feels as though the vertical structure is so strong that I'd make that the controlling aspect, whereupon one could use grouping to adjust the horizontal spacing. – Loop Space Nov 9 '11 at 11:00
  • There's also the dirtree package which is designed for these sorts of trees. In which case Making a (simple) directory tree is a duplicate. – Alan Munn Nov 9 '11 at 12:20
  • @Jake and Andrew Stacey: Sorry for the possible dublicate. I'm perfectly fine with closing this one and/or redirecting answers to the original. I just don't know how to do it. – Martin Heller Nov 9 '11 at 15:30

Browse other questions tagged or ask your own question.