\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[past]}, name=tense2]]
[VP
[V$'$
[AdvP [never, triangle]]
[V$'$ [do, triangle, name=do2]]]]]
\draw[->] (tense2) to[out=south west, in=south] (do2);
\end{forest} \qquad\qquad
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[pres]}, name=tense]]
[VP [do, triangle, name=do]]]
\draw[->] (tense) to[out=south, in=south] (do);
\end{forest}
\end{document}
嗨,我想知道如何为每棵树贴上编号标签,就像我用这段代码发布的图片一样。我试图将 (1a) 和 (1b) 放在每棵树的左侧。有人能帮我吗?
答案1
由于语言学论文中的树被视为语言学示例,因此通常将它们与用于对例句进行编号的系统分开编号是没有帮助的。因此,首先应该从一些不同的编号系统开始,例如编号:
然后问题是如何将它们与使用forest
或创建的树一起使用tikz-qtree
。通常这就像将您的forest
环境放在示例环境中一样简单。由于我使用了 ,所以我用它制作了一个示例,但可以使用或gb4e
做类似的事情。为了获得并排示例,我使用了包。linguex
expex
multicol
这个系统的优点是如果你将树移动到论文中的其他位置,你永远不必担心示例的编号。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{forest}
\usepackage{multicol}
\usepackage{gb4e}
\begin{document}
\begin{exe}
\ex
\begin{multicols}{2}
\begin{xlist}
\ex
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[past]}, name=tense2]]
[VP
[V$'$
[AdvP [never, triangle]]
[V$'$ [do, triangle, name=do2]]]]]
\draw[->] (tense2) to[out=south west, in=south] (do2);
\end{forest}
\ex
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[pres]}, name=tense]]
[VP [do, triangle, name=do]]]
\draw[->] (tense) to[out=south, in=south] (do);
\end{forest}
\end{xlist}
\end{multicols}
\end{exe}
\end{document}
答案2
如果您只想将标签放置为纯文本,则\node
可以使用标准 TikZ :
\documentclass[draft]{article}
\usepackage{forest}
\begin{document}
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[past]}, name=tense2]]
[VP
[V$'$
[AdvP [never, triangle]]
[V$'$ [do, triangle, name=do2]]]]]
\draw[->,overlay] (tense2) to[out=south west, in=south] (do2);
\node[anchor=north east] at (current bounding box.north west) {(1a)};
\end{forest}\qquad\qquad
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[pres]}, name=tense]]
[VP [do, triangle, name=do]]]
\draw[->] (tense) to[out=south, in=south] (do);
\node[anchor=north east] at (current bounding box.north west) {(1b)};
\end{forest}
\end{document}
更新
将text width
键添加到标签\node
s 后,您就可以在里面写入文本(当然,您必须注意宽度,否则可能会获得过满的\hbox
s ):
\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[past]}, name=tense2]]
[VP
[V$'$
[AdvP [never, triangle]]
[V$'$ [do, triangle, name=do2]]]]]
\draw[->,overlay] (tense2) to[out=south west, in=south] (do2);
\node[anchor=north east,text width=3cm,inner xsep=0pt]
at (current bounding box.north west)
{(1a) And here we add some text that will span several lines};
\end{forest}\hfill
\begin{forest} baseline, for tree={parent anchor=south, child anchor=north, align=center, l sep+=0em, s sep+=4em}
[T$'$
[T [{[pres]}, name=tense]]
[VP [do, triangle, name=do]]]
\draw[->] (tense) to[out=south, in=south] (do);
\node[anchor=north east] at (current bounding box.north west) {(1b)};
\end{forest}
\end{document}