我想要设置如下图所示:
我设法使用 重新创建了它forest
,但出于我不明白的原因,\menge
我使用的命令 会将森林树木设置得比实际大得多。我猜这与树木的基线有关。我得到的是:
我能够使用 来修复此问题adjustbox
,但这很麻烦。以下是我所拥有的:
\documentclass{article}
\usepackage{forest}
\usetikzlibrary{tikzmark}
\usepackage{adjustbox}
\newcommand{\menge}[1]{%
\mbox{%
$%
\left\{%
\ignorespaces#1%
\right\}%
$%
%\\[-1.5mm]
}%
}
\begin{document}
\begin{figure}
\menge{
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp1}{VP}]]
\end{forest}}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp2}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp3}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[VP
[geben]
[\subnode{vp4}{VP}]]
\end{forest}
}
\hspace{1em}
\adjustbox{valign=c}{%
\begin{forest}
[\subnode{vp}{VP}
[$\epsilon$]]
\end{forest}
}
\hspace{1em}
}
\begin{tikzpicture}[overlay,remember picture,out=-90,in=90,dashed]
\draw (vp1) to (vp);
\draw (vp2) to (vp);
\draw (vp3) to (vp);
\draw (vp4) to (vp);
\end{tikzpicture}
\caption{Test caption}
\end{figure}
\end{document}
除了看起来多余之外,我的解决方案还无法正确显示完整图形的边界框。虚线突出并干扰了标题。
答案1
数学表达式的括号始终与数学基线对称。绘制独立的括号:
\documentclass{article}
\usepackage{forest}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{figure}
\raisebox{2em}{$\left\{\rule{0pt}{2.75em}\right.$}
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp1}{VP}]]
\end{forest}
\quad
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp2}{VP}]]
\end{forest}
\quad
\begin{forest}
[VP
[NP$\downarrow$]
[\subnode{vp3}{VP}]]
\end{forest}
\quad
\begin{forest}
[VP
[geben]
[\subnode{vp4}{VP}]]
\end{forest}
\quad
\begin{forest}
[\subnode{vp}{VP}
[$\epsilon$]]
\end{forest}
\begin{tikzpicture}[overlay,remember picture,out=-90,in=90,dashed]
\draw (vp1) to (vp);
\draw (vp2) to (vp);
\draw (vp3) to (vp);
\draw (vp4) to (vp);
\end{tikzpicture}
\raisebox{2em}{$\left.\rule{0pt}{2.75em}\right\}$}
\bigskip
\caption{Test caption}
\end{figure}
\end{document}
答案2
您可以使用 TikZ 装饰来绘制括号。诚然,它们很丑,但没有必要将方框升高到任意高度。
\usetikzlibrary{tikzmark,decorations,decorations.pathreplacing}
\newcommand{\menge}[1]{%
\begin{tikzpicture}
\draw node(tree){\ignorespaces#1};
\draw [decorate,decoration=brace]
(tree.south west) -- (tree.north west);
\draw [decorate,decoration=brace]
(tree.north east) -- (tree.south east);
\end{tikzpicture}%
}