I need to typeset a directory tree, and I found here an appropriate solution using forest package. After a slight modification (the squares on the paths, as suggested here), I got this:
Unfortunately, as you can see, the spacing between elements is far from perfect. Take, for example, the vertical distance between text 5.1 and text 6, and that between text 6 and text 5.2: they are (significantly and dreadfully) different, which I don't accept.
Is there a way to solve this problem, that is, to have all elements spaced correctly?
The following is the code for the tree in the picture:
\begin{forest} dir tree,
for tree = {font=\ttfamily}
[text 1
[text 2
[text 3
[text 4
[text 5.1
[text 6]
][text 5.2
]]]]]
\end{forest}
And these are forest settings:
\usepackage{forest}
\forestset{
dir tree/.style={
for tree={
parent anchor=south west,
child anchor=west,
anchor=mid west,
inner ysep=0pt,
grow'=0,
align=left,
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) ++(1em,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
},
if n children=0{}{
delay={
prepend={[,phantom, calign with current]}
}
},
fit=band,
before computing xy={
l=2em
}
},
}
}


drawto the nodes of your original tree. The other is to addx, drawin place of, phantom. It makes it easier to see what is happening. (At least, that's what I did.) – cfr Jan 05 '16 at 22:23