1

I use the following code to produce trees like the two left ones in the figure.

\documentclass{minimal}

\usepackage{forest}

\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word}{}}}, 
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
}


\begin{document}

\begin{forest}
sn edges
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ] 
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ] 
  ]
  [V [gibt\\gives] ]
]
\end{forest}

\end{document}

I would want to decrease this distance so that it looks like the tree on the right (drawn with tikz-qtree). Is there a way to do this (and set it as a default)?

different distances between node labels

1
  • Set l sep for the tree?
    – cfr
    Jul 7, 2014 at 22:21

1 Answer 1

3

Do you want something like

l sep-=<some length>

which will reduce the distance between tiers by <some length>?

The following compares the default with reductions of 1em and 2em respectively:

\documentclass{standalone}

\usepackage{forest}

\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom,where n children=0{tier=word}{}}},
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
}


\begin{document}

\begin{forest}
sn edges
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ]
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ]
  ]
  [V [gibt\\gives] ]
]
\end{forest}
\begin{forest}
  for tree={
    l sep-=1em,
  },
sn edges
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ]
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ]
  ]
  [V [gibt\\gives] ]
]
\end{forest}
\begin{forest}
  for tree={
    l sep-=2em,
  },
sn edges
[S
  [NP [er\\he] ]
  [NP
    [Det [das\\the] ]
    [N [Buch\\book] ]
  ]
  [NP
    [Det [der\\the] ]
    [N [Frau\\woman] ]
  ]
  [V [gibt\\gives] ]
]
\end{forest}

\end{document}

effects of decreasing <code>l sep</code>

4
  • Hm. I am more looking for a general option to change. So, I will put this in the general style definitions. Thanks! Jul 9, 2014 at 8:48
  • @StefanMüller Well that is general. You can define it for the whole document. I just did it this way to demonstrate the effect of different settings in a single image.
    – cfr
    Jul 9, 2014 at 17:09
  • why negative values doen't work? l sep=-10mm Sep 3, 2017 at 23:55
  • 2
    @FiboKowalsky They do, but l sep is a minimum distance. Forest will ensure there's at least that much separation. But it will always make sure that the nodes don't overlap, the children are in the correct direction from the parent etc. So setting l sep to a negative distance is going to do little or nothing more than setting it to zero.
    – cfr
    Sep 4, 2017 at 0:12

You must log in to answer this question.

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