I have many trees in my latex document that are too big and make it hard to make the typesetting of the surrounding text look good. Therefore I want to decrease the vertical length of the tree by decreasing the distance between the nodes. I have tried the solution in this thread, by including this code:
for tree={
l sep-=1em,
},
The only effect is that the distance between the node labeled DP and the node Manne, triangle, is decreased. The rest of them stay the same.
I have loaded the gb4e
package in since I need it in the actual document and no reason related to the actual problem of this post.
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{forest, gb4e}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom{}}},
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,}},
qtree/.style={
baseline,
for tree={
parent anchor=south,
child anchor=north,
align=center,
inner sep=1pt,
}},
nice empty nodes/.style={for tree={calign=fixed edge angles},delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}
\tikzset{every tree node/.style={align=center,anchor=north}}
\begin{document}
\begin{exe}
\ex
\begin{forest}
for tree={
l sep-=1em,
},
qtree, nice empty nodes,
[TP
[T]
[\textit{v}P,
[AdvP
[sneehpeslaakan, triangle]]
[\textit{v}P
[DP
[Manne, triangle]]
[{}, s sep=15pt
[VP
[DP
[gærjah, triangle]]
[t{\scriptsize V}]]
[\textit{v} \\ lohk]]]]]
\end{forest}
%\end{xlist}
\end{exe}
\end{document}
I get the following output:
Best Answer
The problem is due to the way the
nice empty nodes
style is defined. Here's a solution which gives a slightly different definition ofnice empty nodes
which I callfairly nice empty nodes
. This definition will probably not be as successful with long strings of empty nodes, but for the occasional one as in your tree, it works quite well.I've made some simplifications to your code, much of which has now been incorporated into the
linguistics
library offorest
. I've also removed theutf8x
input encoding, which generally shouldn't be used. Thetriangle
style isn't defined by default, but there is aroof
style which is, so I've used that instead. This is usingforest
v. 2.0.3 from TeXLive 2016v. 2.15 from TeXLive 2017. Code has been updated to reflect recent changes.If you really want to squish the tree further, you can set
l=0
and then change the value ofl sep-
to something a bit smaller. For example, settingyields the following output:
Forest v.1 version
It appears you are using
forest
v.1, which is why your code wouldn't compile for me. So here's a version using that version offorest
. I've left the other code in the answer, sinceforest
v.1 is now more than two years old, and hasn't been part of TeX Live since 2014, so other people who find this question (or you, if you update) may find the newer code useful.