I want to align three trees in the way shown in the following figure:
What I have now is the following code:
\documentclass{minimal}
\usepackage{forest}
\forestset{
tag/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top},where
n children=0{}{}}
}
\begin{document}
\hfill
\begin{forest}
tag
[NP
[John]]
\end{forest}
\hfill
\begin{forest}
tag
[S
[NP$\downarrow$]
[VP
[V
[laughs]]]]
\end{forest}
\hfill
\begin{forest}
tag
[VP
[ADV
[always]]
[VP*]]
\end{forest}
\hfill\mbox{}
\end{document}
I know of the baseline
attribute, but this would not do real centering. Before using forest
I just used tables and this got the alignment right automatically.
Best Answer
I can think of two ways of accompishing this without external help. Both use the fact that
tikz
/pgf
keeps track of the picture's bounds in a special node calledcurrent bounding box
.Use
tikz
'sbaseline
option, which must be given as an argument totikzpicture
environment. This can be achieved by changingforest
's optionbegin draw
(at any node, but probably in the preamble)Use
pgf
's\pgfsetbaselinepointlater
, which can be injected fromforest
' by usingforest
'stikz
option (again, at any node, but probably in the preamble).In your example, use this definition of
tag
style (the first way is active, the second way is commented out):