语言学森林:改变箭头的出口位置

语言学森林:改变箭头的出口位置

我是一名新手,想问一个关于使用 Forest 语言树中的箭头的简单问题。以下希望是最简单的示例,箭头尾部位于屋顶(三角形)下方:

\documentclass{article}
\usepackage[linguistics]{forest}

\begin{document}
\begin{forest}
for tree={s sep=15mm, inner sep=5, l=0}
[TP, s sep=10mm [DP,name=specTP]
[T$'$, s sep=10mm [T] 
[VP [ \_\_read the book, roof,name=VP]]
]
]
]
{\draw[->] (VP) to[out=south,in=south] (specTP);}
\end{forest}
\end{document}

其结果为:

在此处输入图片描述

我希望箭头尾部从“read”前面的下划线向南,而不是从屋顶文本的中心向南。在这种情况下,我几乎可以通过将“south”替换为“west”来获得我需要的结果,但如果有一种简单的方法可以做到这一点,那将很有用。

答案1

您可以使用例如来修改起始坐标([xshift=1em]VP.south west)

\documentclass{article}
\usepackage[linguistics]{forest}

\begin{document}
\begin{forest}
for tree={s sep=15mm, inner sep=5, l=0}
[TP, s sep=10mm [DP,name=specTP]
[T$'$, s sep=10mm [T] 
[VP [ \_\_read the book, roof,name=VP]]
]
]
]
{\draw[->] ([xshift=1em]VP.south west) to[out=south,in=south] (specTP);}
\end{forest}
\end{document}

在此处输入图片描述

答案2

在这种情况下,手动移动效果很好,但还有另一种方法,在更复杂的情况下非常有用。这是使用\subnode提供的命令tikzmark来标记节点和节点的一部分。然后使用单独的将注释叠加在树上tikzpicture

\documentclass[border=10pt]{standalone}
\usepackage[linguistics]{forest}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{forest}
  for tree={s sep'=15mm, inner sep=5}
  [TP, s sep'=10mm
    [\subnode{specTP}{DP}]
    [T$'$, s sep'=10mm
      [T]
      [VP
        [ \subnode{a}{\_\_}read the book, roof]
      ]
    ]
  ]
\end{forest}
\tikz[overlay, remember picture]{\draw[->] (a.south) to [out=south,in=south] (specTP);}
\end{document}

请注意,我已删除它,l=0因为它对这棵树没有任何影响。

叠加注释

相关内容