14

How can I change the scale of a tree made with the forestpackage? I work with beamer, and sometimes my trees are a bit too wide, so they finish after the limit of the frame :

\documentclass{beamer}
\usepackage{forest, philex}

\begin{document}

\begin{frame}{Mise en pratique}
\begin{exampleblock}{}
    Comment représenter la structure suivante :
\end{exampleblock}
\lb{}{
    \lba{}{J'ai [vu un âne gris dans le clocher].}
    \lbb{}{[vu [un [âne [gris] ] ] [dans [le [clocher] ] ] ]}
    \lbz{}{
        \begin{forest} baseline, for tree={parent anchor=south, calign=first}
            [VP
                [VP
                    [V\\\textit{vu}, align=center, base=top]
                    [DP
                        [D\\\textit{un}, align=center, base=top]
                        [NP
                            [N\\\textit{âne}, align=center, base=top]
                            [AP [A\\\textit{gris}, align=center, base=top]]
                        ]
                    ]
                ]
                [PP
                    [P\\\textit{dans}, align=center, base=top]
                    [DP
                        [D\\\textit{le}, align=center, base=top]
                        [NP
                            [N\\\textit{clocher}, align=center, base=top]
                        ]
                    ]
                ]
            ]
\end{forest}}}

\end{frame}

\end{document}

With tikz-qtree, the option [scale=.8] was available, but it doesn't seem to work with forest. Any idea?

BonyHoax
  • 969

2 Answers2

16

Here, I wrap it in a \scalebox (in this MWE, to 0.7 scale).

\documentclass{beamer}
\usepackage{forest, philex}
\usepackage{graphicx}
\begin{document}
\begin{frame}{Mise en pratique}
\begin{exampleblock}{}
    Comment représenter la structure suivante :
\end{exampleblock}
\lb{}{
    \lba{}{J'ai [vu un âne gris dans le clocher].}
    \lbb{}{[vu [un [âne [gris] ] ] [dans [le [clocher] ] ] ]}
    \lbz{}{
       \scalebox{0.7}{
        \begin{forest} baseline, for tree={parent anchor=south, calign=first}
            [VP
                [VP
                    [V\\\textit{vu}, align=center, base=top]
                    [DP
                        [D\\\textit{un}, align=center, base=top]
                        [NP
                            [N\\\textit{âne}, align=center, base=top]
                            [AP [A\\\textit{gris}, align=center, base=top]]
                        ]
                    ]
                ]
                [PP
                    [P\\\textit{dans}, align=center, base=top]
                    [DP
                        [D\\\textit{le}, align=center, base=top]
                        [NP
                            [N\\\textit{clocher}, align=center, base=top]
                        ]
                    ]
                ]
            ]
\end{forest}}}}
\end{frame}
\end{document}

enter image description here

5

In addition to the option of changing the font size with e.g. \footnotesize you could also modify the separation between the levels of the tree, with the l and l sep parameters. Both are demonstrated below:

\documentclass{beamer}
\usepackage{forest, philex}

\begin{document}

\begin{frame}{Mise en pratique}
\begin{exampleblock}{}
    Comment représenter la structure suivante :
\end{exampleblock}
\lb{}{
    \lba{}{J'ai [vu un âne gris dans le clocher].}
    \lbb{}{[vu [un [âne [gris] ] ] [dans [le [clocher] ] ] ]}
    \lbz{}{
        \begin{forest} baseline, for tree={parent anchor=south, calign=first,l=0pt,l sep=4pt}
            [VP
                [VP
                    [V\\\textit{vu}, align=center, base=top]
                    [DP
                        [D\\\textit{un}, align=center, base=top]
                        [NP
                            [N\\\textit{âne}, align=center, base=top]
                            [AP [A\\\textit{gris}, align=center, base=top]]
                        ]
                    ]
                ]
                [PP
                    [P\\\textit{dans}, align=center, base=top]
                    [DP
                        [D\\\textit{le}, align=center, base=top]
                        [NP
                            [N\\\textit{clocher}, align=center, base=top]
                        ]
                    ]
                ]
            ]
\end{forest}}}

\end{frame}
\begin{frame}{Mise en pratique}
\begin{exampleblock}{}
    Comment représenter la structure suivante :
\end{exampleblock}
\lb{}{
    \lba{}{J'ai [vu un âne gris dans le clocher].}
    \lbb{}{[vu [un [âne [gris] ] ] [dans [le [clocher] ] ] ]}
    \lbz{}{\footnotesize
        \begin{forest} baseline, for tree={parent anchor=south, calign=first}
            [VP
                [VP
                    [V\\\textit{vu}, align=center, base=top]
                    [DP
                        [D\\\textit{un}, align=center, base=top]
                        [NP
                            [N\\\textit{âne}, align=center, base=top]
                            [AP [A\\\textit{gris}, align=center, base=top]]
                        ]
                    ]
                ]
                [PP
                    [P\\\textit{dans}, align=center, base=top]
                    [DP
                        [D\\\textit{le}, align=center, base=top]
                        [NP
                            [N\\\textit{clocher}, align=center, base=top]
                        ]
                    ]
                ]
            ]
\end{forest}}}

\end{frame}

\end{document}

enter image description here

Torbjørn T.
  • 206,688