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.


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:




\tikzstyle{every node}=[draw=black,thick,anchor=west]

    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)}]
        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}}


This produces the following result: enter image description here

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?


1 Answer 1


like this?

enter image description here

with forest package this is simple to obtain:


    for tree={grow'=0,  % direction
              folder,   % show folder organization
              draw,     % nodes have borders
              l sep'=6mm
        [Quite a long text here
          [Another long text for a wide box
            [More text]
  • Wow, that looks so much simpler! And yes, that is precisely what I was looking for. Thank you very much! Mar 9, 2018 at 15:45
  • l sep'=6mm is quicker.
    – cfr
    Mar 10, 2018 at 0:17
  • @cfr, is difference at this simple short code observable? anyway, i corrected my answer. thank you very much.
    – Zarko
    Mar 10, 2018 at 1:02
  • No. Well, technically, I guess it depends on processing speed and what is doing the noticing but, no. Your answer wasn't incorrect by any means: it was just a comment ;).
    – cfr
    Mar 10, 2018 at 2:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .