6

I would like to have more space between the first level and the second level in the tree below. In tikz-qtree I can use

\tikzset{level 1+/.style={level distance=3\baselineskip}} \tikzset{level 2+/.style={level distance=2\baselineskip}}

Is there something equivalent in forest?

\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}
2
  • Have you looked at section 4.2 in the forest manual? Commented Mar 27, 2014 at 10:32
  • Thanks. The text before the example explains that it is an answer to my question, but it is not the best way to display this answer. This example is highly complex. Is the answer to shift all the nodes you want to be lowered manually? Hm. Commented Mar 27, 2014 at 10:50

1 Answer 1

5

Do you want something like

l sep+=<some length>

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

To restrict this increase to only the distance between the root node and the first tier, you can use

for children={
  l sep-=<some length>,
}

to reverse the increase. (There may be a more direct method - this is just what came most readily to hand.)

The following compares the default with increases 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}
sn edges,
l sep+=1em,
for children={
  l sep-=1em,
}
[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}
sn edges,
l sep+=2em,
for children={
  l sep-=2em,
}
[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}

effect of increasing <code>l sep</code> for the root node

4
  • This only works for increasing the level distance, or for decreasing it once it has been increased (but not below a certain threshold). Is there a way to decrease the initial value in a similar way?
    – Timm
    Commented Jul 1, 2015 at 14:14
  • @Timm You can use l sep-=<whatever>. It isn't restricted to reversing the effect of an earlier increase. Or you can specify l sep=<absolute value> to override the initial value completely. Is that what you mean?
    – cfr
    Commented Jul 1, 2015 at 15:15
  • 1
    Yes, I'd like to override the initial value. But I don't get less than a certain distance. I can increase it like this [A [B,l=50mm][C,l=50mm]], but it's not possible for me to make it zero like this [A [B,l=0mm][C,l=0mm]]. I've also tried l sep and negative values. Hm.
    – Timm
    Commented Jul 2, 2015 at 7:35
  • @Timm Since this question was about something else, I think you should post a new question with an example of what you are trying to do. It isn't easy to figure this stuff out in comments. Note that l sep is the minimum distance between levels. It isn't intended to be the maximum.
    – cfr
    Commented Jul 2, 2015 at 12:11

You must log in to answer this question.

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