我想在表格第一列的每个单元格中放置一棵森林树。这样做时会出现一些问题:间距太小,表格其余部分的数字会移到底部。我对如何使用它了解不够多,无法forest
弄清楚如何在它周围添加间距,我也不知道它如何与乳胶表交互。这是它现在的样子:
梅威瑟:
\documentclass{article}
\begin{document}
\begin{equation*}
\begin{array}{|c|c|c|}\hline
\text{Tree} & N_L(T) & \frac{1}{3}N(T) \\\hline
\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[]
\end{forest}
& 1 & \frac{1}{3} \\\hline
\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[,no edge, draw=none][]]
\end{forest}
& 1 & \frac{2}{3} \\\hline
\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[][,no edge, draw=none]]
\end{forest}
& 1 & \frac{2}{3} \\\hline
\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[][]]
\end{forest}
& 2 & 1 \\\hline
\end{array}
\end{equation*}
\end{document}
答案1
这是一个建议。
- 将
forest
s 包裹进去\vcenter{\hbox{...}}
以使它们垂直居中。 forest
基于 Ti钾Z,并且在方程中,即局部地,每个的边界框都会增加。与或tikzpicture
等标准方法相比,这使我们能够获得更精细的填充控制。\renewcommand{\arraystretch}{...}
\\[...]
\documentclass{article}
\usepackage{amsmath}
\usepackage{forest}
\begin{document}
\begin{equation*}\tikzset{every picture/.append style={execute at end picture={%
\path (current bounding box.north) +(0,1ex) (current bounding box.south) +(0,-1ex);}}}
\begin{array}{|c|c|c|}\hline
\text{Tree} & N_L(T) & \frac{1}{3}N(T) \\\hline
\vcenter{\hbox{\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[]
\end{forest}}}
& 1 & \frac{1}{3} \\\hline
\vcenter{\hbox{\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[,no edge, draw=none][]]
\end{forest}}}
& 1 & \frac{2}{3} \\\hline
\vcenter{\hbox{\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[][,no edge, draw=none]]
\end{forest}}}
& 1 & \frac{2}{3} \\\hline
\vcenter{\hbox{\begin{forest}
for tree={ grow=south, circle, draw, minimum size=3ex, inner sep=1pt, s sep=3mm }
[[][]]
\end{forest}}}
& 2 & 1 \\\hline
\end{array}
\end{equation*}
\end{document}