I want to create a dependency diagram such as the following: dependency diagram

So far, I have done this using TikZ:


\def\mytext{The man}


      shape = rectangle,
      inner sep = 2pt,
      anchor=south west,
    \draw[thin] (0,0) -- (\basewidth + 2ex,0);
    \draw[thin] (0,0) -- (0, 1.5em);
    draw (0,0) \node[firstnode,
    minimum width = \basewidth] {\mytext};

Which gives me the following output:

my output

How may I complete the diagram (in repeatable, efficient way)?

  • Welcome! Did you have a look at the forest package?
    – user121799
    Feb 25, 2019 at 2:21
  • Thanks! Yes, but those aren't the kind of diagrams I want. I need this other kind to help my students easily grasp the sentence syntax.
    – p.lugan
    Feb 25, 2019 at 2:28

1 Answer 1


How about this?

grow'=0,edge = {semithick},
edge path'={(!u.south-|.south west) |- (.south east)},
anchor=west,l sep=2.5em,s sep=0em}}
for tree={students}
[The man
 [who lept
  [over the wall]
for tree={students}
 [to mother
 [because he loves her
for tree={students}

enter image description here

In this update, I added the second tree for illustration and packed all the definitions in a style that you can recycle, and which allows you to make changes globally. The relative vertical alignment is adapted from this nice answer.

  • That's great! But is there a way of reducing the vertical space of the nodes?
    – p.lugan
    Feb 25, 2019 at 2:44
  • @p.lugan Of course/ Just add s sep=0em after l sep=2.5em.
    – user121799
    Feb 25, 2019 at 2:45
  • Perfect. Just a side question: how can I manage to learn to do that by myself? The PGF/TikZ manual is simple overwhelming!
    – p.lugan
    Feb 25, 2019 at 2:48
  • @p.lugan For this you may want to look at the forest manual first. (I will add an update. The most important thing there, apart from forest, will be this post.)
    – user121799
    Feb 25, 2019 at 2:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.