我是 latex 包的新手forest
。如何在 中实现预期结果LaTeX
。如何arrows
在 forest 包中移动?
我的 MWE 是:
\documentclass{beamer}
\usepackage{qtree}
\usepackage[linguistics]{forest}
\useforestlibrary{linguistics}
\usetikzlibrary{shapes.geometric}
\usepackage{mathptm}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north}},
background tree/.style={for tree={
text opacity=0.8,draw opacity=0.8,edge={draw opacity=0.8}}}
}
\begin{document}
\centering
\begin{forest}
[\textrm{CP},
[\phantom{xxxxxxxxxxxxxxxxxxxx}\v{\!\!\!\d{c}}\hbox{'}al-$\textrm{ew}_{\textrm{i}}$\phantom{xxxxxxxxxxxxxxxxxxxx},name=spec CP]
[$\textrm{C}^\prime$
[\phantom{xxxxxxx}TP\phantom{xxxxxxx}
[\phantom{xxxxxxx}vP\phantom{xxxxxxx}
[\phantom{xxxxxxx}DP\phantom{xxxxxxx}
[$\textrm{Op}_{\textrm{i}}$,name=spec PC]
[PossP
[\!\!\!$_{-\!\!\!-\!\!\!-\!\!\!-\!\!\!-}{_{\textrm{PG}}}$ z-\v{s}, name=objects, roof]]]
[$\textrm{v}^\prime$
[\!\!\!$t_i({{\scriptstyle{\textrm{IO}}}}) \emptyset${-ze-r-j-t}, name=object, roof]]]
[T[-e]]]
[C${[{\scriptstyle{\textrm{WH}}}]}$]
]
]
\draw[->] (object) to[out=south west,in=south] (spec CP);
\draw[->] (objects) to[out=south west,in=south] (spec PC);
\end{forest}
\end{document}
答案1
严格来说,绘制箭头是 TikZ 的事情,即使是在森林树中绘制也是如此。我想这是一门艺术——PGF/TikZ 手册的第 13 章和第 15 章是这里的终极参考来源,该手册中的教程也应该会很有帮助。
继续讨论森林业务,有两个技巧必须使用才能得到所需的树。第一个很简单:“fit=band”将创建一个下面没有任何内容的节点;当嵌入“for tree”时,如下所示,我们得到一个“宽”树。(因此,“for tree={fit=band}”消除了对 OP 的幻象“xxx”的需求。)
第二个技巧很复杂。我们如何让外箭头在绕 DP 子树一圈后笔直向上射出?如果我们对此不做任何处理,它会稍微向左射出,因为“č'al-ew_i”向左移动太多——请记住,“fit=band”的效果是将节点下方的空间留空。这里的想法是使用空节点排版树——下面,我另外删除了 (i) 该节点的内部 x 空间和 (ii) 节点与其兄弟节点之间的“s 分隔”——然后才放入所需的内容。要了解如何绘制箭头本身,请查看(注释的)代码。
我还擅自清理了代码。我删除了\textsubscript
用于文本模式下标的多余的包、用于语音符号的包\textipa
(来自包)和用于功能的包(小写字母)。tipa
\textsc
\documentclass{beamer}
\usepackage[linguistics]{forest}
\usepackage{tipa}
\begin{document}
\centering
\begin{forest}
for tree={
plain content, % The linguistics library default has a little bug which results in some undesired space below each node. (The culprit is "align=center" in "default preamble".) Key "plain content" reverses that, but note that it only allows for single-line nodes.
fit=band, % Removing this will result in a more compact tree.
},
[CP,
[% \d{\v{c}}'al-ew\textsubscript{i},
% We don't set the content of the node right away (it is commented out above), but rather pack the tree with this node empty --- which results in the center of "č'al-ew_i" being right above the west of Op_i --- and swap the empty node for the real node only just before drawing the tree.
,inner xsep=0, for parent={s sep=0}, before drawing tree={content=\d{\v{c}}'al-ew\textsubscript{i}, typeset node},
name=spec CP,
fit=band, % Strictly speaking, this is not necessary, it is only here so that if we remove the upper "fit=band", the arrow to spec-CP still shoots straight up.
]
[C$^\prime$
[TP
[vP
[DP
[Op\textsubscript{i},name=Op] % text mode subscript
[PossP
[\textsubscript{\text{------PG}} \textipa{z@-\v{s}}, inner xsep=0, roof]
% "---" = em dash
{\draw[->] () to[out=south west,in=south] (Op);}
]
]
[v$^\prime$
[$t$\textsubscript{i}(\textsc{io}) $\emptyset$\textipa{-ze-r-j@-t@}, roof, inner xsep=0]
{\draw[->,overlay]
(.south west) % start at the bottom left of the node
+(1.2em,0pt) % move a bit to the right, without drawing a line
to[out=south,in=south,looseness=2]
(Op.west) % loop to the west of Op_i, loosely ("looseness" sets two parameters, "in looseness" and "out looseness")
-- (spec CP);}
]
]
[T[\textipa{-Ke}]] % IPA
]
[{C[\textsc{wh}]}] % small caps
]
]
\end{forest}
\end{document}