# Decreasing the distance between node labels and connecting lines in forest

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)?

• Set l sep for the tree? – cfr Jul 7 '14 at 22:21

## 1 Answer

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}


• Hm. I am more looking for a general option to change. So, I will put this in the general style definitions. Thanks! – Stefan Müller Jul 9 '14 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 '14 at 17:09
• why negative values doen't work? l sep=-10mm – Fibo Kowalsky Sep 3 '17 at 23:55
• @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 '17 at 0:12