我在用森林包来编写一些带有平面树的代数。但是,当我将自动调整大小的括号与我的森林图片相结合时,括号的大小和位置完全错误:它一直延伸到森林下方。我如何获得适当大小和位置的括号?
\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}
答案1
不要使用$$ ... $$
,而要使用\[ ... \]
。您需要将树垂直居中,这可以使用 来完成\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}