排版树并连接森林中 AVM 内的节点和子节点

排版树并连接森林中 AVM 内的节点和子节点

对于排版 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}

代码输出

相关内容