I've drawn a directory listing style tree using code similar to that found in Drawing a directory listing a la the tree command in TikZ. I'll repeat it here for clarity
\documentclass[border=10]{standalone}
\usepackage{tikz}
\makeatletter
\newcount\dirtree@lvl
\newcount\dirtree@plvl
\newcount\dirtree@clvl
\def\dirtree@growth{%
\ifnum\tikznumberofcurrentchild=1\relax
\global\advance\dirtree@plvl by 1
\expandafter\xdef\csname dirtree@p@\the\dirtree@plvl\endcsname{\the\dirtree@lvl}
\fi
\global\advance\dirtree@lvl by 1\relax
\dirtree@clvl=\dirtree@lvl
\advance\dirtree@clvl by -\csname dirtree@p@\the\dirtree@plvl\endcsname
\pgf@xa=1cm\relax
\pgf@ya=-1cm\relax
\pgf@ya=\dirtree@clvl\pgf@ya
\pgftransformshift{\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
\ifnum\tikznumberofcurrentchild=\tikznumberofchildren
\global\advance\dirtree@plvl by -1
\fi
}
\tikzset{
dirtree/.style={
growth function=\dirtree@growth,
every node/.style={anchor=north},
every child node/.style={anchor=west},
edge from parent path={(\tikzparentnode\tikzparentanchor) |- (\tikzchildnode\tikzchildanchor)}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}[dirtree]
\node {toplevel}
child { node {Foo}
child { node {foo} }
child { node {bar} }
child { node {baz} }
}
child { node {Bar}
child { node {foo} }
child { node {foo} }
child { node {foo} }
child { node {foo} }
child { node {bar} }
child { node {baz} }
}
child { node {Baz}
child { node {foo} }
child { node {bar} }
child { node {baz} }
};
\end{tikzpicture}
\end{document}
My question is: how can I reduce the indentation of the child nodes?
Currently the anchor point comes from the south of the parent node which means the tree becomes large horizontally very quickly. I do not wish to use the parents' west as the anchor point. Ideally a point between the two would be better so the output looks like:
Root
|___ First Parent
|__First Child
|_ Grand Child
Rather than
Root
|___ First Parent
|__First Child
|_ Grand Child
Any thoughts much appreciated


Foobarishare still not aligned with the children ofBarso this only solves the part of the problem relating to drawing the paths. I think that to align all the children and grandchildren one would need to adjust things a bit deeper. Trees are drawn by transforming first to the centre of the parent node. This is what would need changing, I think. – Andrew Stacey Jan 04 '13 at 10:06every child node/.style, this would work, but it is really complicated to fiddle out good values for bothxshifts, then. I at last decided to change all parent anchors tosouth. In my case now the vertical lines are still almost aligned, because the nodes are almost the same length. – Speravir Jan 06 '13 at 00:50anchor=1em right of south west. BTW please add a remark in the code, that the value ofxshiftcan be and perhaps should be adjusted to one’s own needs. – Speravir Jan 06 '13 at 00:52