TLDR: I would like the coordinate shift specified at the start of a Tikzpicture to be interpreted relative to the western edge of the node above, rather than the center, but couldn't find how.
Hi,
I am trying to create a horizontally growing Tikz tree in LaTeX with text at the nodes, and as the tree has quite a number of levels and some of the text can be somewhat long, I want to be as sparingly as possible with horizontal space.
I have set everything up more or less as I want it, but the problem is that the coordinate shift I set up for each new level seems to begin at the center of the text field, which means the horizontal shift for a new level can be much further than desired for wide text boxes. I would like to be able to set the coordinate shift relative to the west edge of the text boxes. Just setting anchor to west doesn't seem to work, because the line just elongates horizontally.
Here's a MWE:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\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.west) |- (\tikzchildnode.west)}]
\node[anchor=west]{}
child { node[anchor=west] {Text}}
child { node[anchor=west] {Quite a long text here}
child { node[anchor=west] {Another long text for a wide box}
child { node[anchor=west] {More text}}
}
};
\end{tikzpicture}
\end{document}
This produces the following result:
As you can see, the lower two text boxes are shifted horizontally by the desired amount (compare "Text" relative to the root node) relative to the center of the above level, which means they still extend very far, horizontally. Is there any way I can make the coordinate shift be interpreted as relative to the left/western edge of the above level's text box?
Thanks!