TransWikia.com

Forest package and weird bracket behaviour

TeX - LaTeX Asked by Dasha Poliakova on January 30, 2021

I am using forest package to write some algebra with planar trees. However, when I combine automatically sized brackets with my forest picture, the bracket size and position is completely wrong: it goes all the way below the forest. How do I get the adequately sized and positioned brackets?

documentclass{article}
usepackage[utf8]{inputenc}

usepackage{forest}

begin{document}
$$left ( begin{forest}
for tree = {grow'=90,circle, fill, minimum width = 4pt, inner sep = 0pt, s sep = 13pt}
[{},phantom
[{},name = one [[]] [[][]] ]
[{},name = two [[]] [[]] ]
]
draw[black] (one) -- (two);
end{forest},
begin{forest}
for tree = {grow'=90,circle, fill, minimum width = 4pt, inner sep = 0pt, s sep = 13pt}
[{},phantom
[{},name = one [[]] [[][]] ]
[{},name = two [[]] [[]] ]
[{},name = three [  [][]]]
[{},name = four [ [] [] []] [[]]  ]
]
draw[black] (one) -- (two) -- (three) -- (four);
end{forest} right )$$

end{document}

This is what happens

One Answer

Do not use $$ ... $$ but use [ ... ] instead. You need to center the tree vertically, which can be done with vcenter.

documentclass{article}
usepackage[utf8]{inputenc}

usepackage{forest}

begin{document}
[left (vcenter{hbox{begin{forest}
for tree = {grow'=90,circle, fill, minimum width = 4pt, inner sep = 0pt, s sep = 13pt}
[{},phantom
[{},name = one [[]] [[][]] ]
[{},name = two [[]] [[]] ]
]
draw[black] (one) -- (two);
end{forest},
begin{forest}
for tree = {grow'=90,circle, fill, minimum width = 4pt, inner sep = 0pt, s sep = 13pt}
[{},phantom
[{},name = one [[]] [[][]] ]
[{},name = two [[]] [[]] ]
[{},name = three [  [][]]]
[{},name = four [ [] [] []] [[]]  ]
]
draw[black] (one) -- (two) -- (three) -- (four);
end{forest}}} right )]

end{document}

enter image description here

Answered by user228539 on January 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP