![排版树并连接森林中 AVM 内的节点和子节点](https://linux22.com/image/363949/%E6%8E%92%E7%89%88%E6%A0%91%E5%B9%B6%E8%BF%9E%E6%8E%A5%E6%A3%AE%E6%9E%97%E4%B8%AD%20AVM%20%E5%86%85%E7%9A%84%E8%8A%82%E7%82%B9%E5%92%8C%E5%AD%90%E8%8A%82%E7%82%B9.png)
对于排版 LFG 分析,必须将树中的节点与属性值矩阵 (AVM) 的部分连接起来。我曾tcolorbox
这样做过。(参见http://tex.stackexchange.com/questions/218417/replacing-tree-dvips-connect-nodes-in-a-tabular-environment/218458#218458)。可以将一个 AVM 或子 AVM 定义为一个节点并为其命名。然后可以用箭头连接节点。问题是此代码停止工作,可能有更好的方法来实现此功能。
类似的代码在 texlive 2013 下运行(并生成上图),但无法在 2017 下运行。我正在寻找一种简单的方法,将这样的箭头从树中的节点和子节点绘制到 AVM 中。
\documentclass{article}
\usepackage{array}
\def\lfgms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{@{}>{\scshape}l@{\hspace{5pt}}>{\small}l@{}}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}
%http://tex.stackexchange.com/questions/218417/replacing-tree-dvips-connect-nodes-in-a-tabular-environment/218458#218458
\usepackage{tcolorbox}
\tcbuselibrary{skins}
% for texlive 2015
\newtcbox{\mybox}[1][]{empty,shrink tight,nobeforeafter,on line,before upper=\vphantom{gM},remember as=#1,top=2pt,bottom=2pt}
\newcommand{\mynode}[2]{\mybox[#1]{#2}}
\usepackage[linguistics]{forest}
\usetikzlibrary{tikzmark}
\newcommand{\centtab}[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
\begin{document}
\begin{forest}
sn edges
[VP, name=vp1
[\centtab{(\textsc{subj}) = d\\
\subnode{npsubj}{NP}}
[David]]
[VP, name=vp2
[\centtab{(\textsc{obj}) = d\\
\subnode{npobj}{NP}}
[den Apfel, roof]]
[VP,name=vp3
[V,name=v
[verschlingt]]]]]
\end{forest}\hfill
\raisebox{5em}{%
\mynode{all}{\lfgms{ pred & `DUMMY{\textsc{subj},\textsc{obj}}'~~\\
subj & \mynode{fdavid}{\lfgms{ pred & `DAVID' \\
}}\\
tense & PRES\\
obj & \mynode{fapple}{\lfgms{ pred & `APFEL'\\
}}}}}
\begin{tikzpicture}[overlay,remember picture]
\draw[->] (vp1) to[out= 0,in=180] (all.west);
\draw[->] (vp2) to[out= 0,in=180] (all.west);
\draw[->] (vp3) to[out= 0,in=180] (all.west);
\draw[->] (v) to[out= 0,in=180] (all.west);
\draw[->] (npsubj) to[out=15,in=210] (fdavid.west);
\draw[->] (npobj) to[out= 0,in=210] (fapple.west);
\end{tikzpicture}
\end{document}
编辑3:
以下内容适用于pdflatex
但不适用于xelatex
:
\documentclass{article}
\usepackage{array}
\def\lfgms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{@{}>{\scshape}l@{\hspace{5pt}}>{\small}l@{}}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}
\newcommand{\mynode}[2]%
{\tikz[baseline=(#1.base), remember picture]\node[outer sep=0pt, inner sep=0pt] (#1) {#2};}
\usepackage[linguistics]{forest}
\usetikzlibrary{tikzmark}
\newcommand{\centtab}[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
\begin{document}
\begin{forest}
sn edges
[\subnode{vp1}{VP}
[\centtab{(\textsc{subj}) = d\\
\subnode{npsubj}{NP}}
[David]]
[\subnode{vp2}{VP}
[\centtab{(\textsc{obj}) = d\\
\subnode{npobj}{NP}}
[den Apfel, roof]]
[\subnode{vp3}{VP}
[\subnode{v}{V}
[verschlingt]]]]]
\end{forest}\hfill
\raisebox{5em}{%
\mynode{all}{\lfgms{ pred & `DUMMY{\textsc{subj},\textsc{obj}}'~~\\
subj & \mynode{fdavid}{\lfgms{ pred & `DAVID' \\
}}\\
tense & PRES\\
obj & \mynode{fapple}{\lfgms{ pred & `APFEL'\\
}}}}}
\begin{tikzpicture}[overlay,remember picture]
\draw[->] (vp1) to[out= 0,in=180] (all.west);
\draw[->] (vp2) to[out= 0,in=180] (all.west);
\draw[->] (vp3) to[out= 0,in=180] (all.west);
\draw[->] (v) to[out= 0,in=180] (all.west);
\draw[->] (npsubj) to[out=15,in=210] (fdavid.west);
\draw[->] (npobj) to[out= 0,in=210] (fapple.west);
\end{tikzpicture}
\end{document}
答案1
虽然您的示例文档无法与 XeLaTeX 配合使用,但它可以与 LuaLaTeX 配合使用。在许多用例中,LuaLaTeX 可以替代 XeLaTeX,且代码完全无需更改。
\documentclass{article}
\usepackage{array}
\def\lfgms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{@{}>{\scshape}l@{\hspace{5pt}}>{\small}l@{}}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}
\newcommand{\mynode}[2]%
{\tikz[baseline=(#1.base), remember picture]\node[outer sep=0pt, inner sep=0pt] (#1) {#2};}
\usepackage[linguistics]{forest}
\usetikzlibrary{tikzmark}
\newcommand{\centtab}[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
\begin{document}
\begin{forest}
sn edges
[\subnode{vp1}{VP}
[\centtab{(\textsc{subj}) = d\\
\subnode{npsubj}{NP}}
[David]]
[\subnode{vp2}{VP}
[\centtab{(\textsc{obj}) = d\\
\subnode{npobj}{NP}}
[den Apfel, roof]]
[\subnode{vp3}{VP}
[\subnode{v}{V}
[verschlingt]]]]]
\end{forest}\hfill
\raisebox{5em}{%
\mynode{all}{\lfgms{ pred & `DUMMY{\textsc{subj},\textsc{obj}}'~~\\
subj & \mynode{fdavid}{\lfgms{ pred & `DAVID' \\
}}\\
tense & PRES\\
obj & \mynode{fapple}{\lfgms{ pred & `APFEL'\\
}}}}}
\begin{tikzpicture}[overlay,remember picture]
\draw[->] (vp1) to[out= 0,in=180] (all.west);
\draw[->] (vp2) to[out= 0,in=180] (all.west);
\draw[->] (vp3) to[out= 0,in=180] (all.west);
\draw[->] (v) to[out= 0,in=180] (all.west);
\draw[->] (npsubj) to[out=15,in=210] (fdavid.west);
\draw[->] (npobj) to[out= 0,in=210] (fapple.west);
\end{tikzpicture}
\end{document}