\documentclass[12pt]{article}
\usepackage{forest}
\usepackage{gb4e,cgloss}
\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom{}}},
background tree/.style={for tree={text opacity=0.2,draw opacity=0.2,}},
qtree/.style={
baseline,
for tree={
parent anchor=south,
child anchor=north,
align=center,
inner sep=1pt,
}},
nice empty nodes/.style={for tree={calign=fixed edge angles},delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}
\begin{document}
\begin{exe}
\ex
\begin{forest} qtree, nice empty nodes,
[…, for descendants={l=0}, name=dots , tikz={\node [draw,green,inner sep=12pt, fit=(V)(dots)(book)(Erel)(v)(T)] {};}
[ \emph{v}P
[DP
[Erel, triangle, name=Erel ] ]
[ {}, s sep=5em
[VP, name=VP, tikz={\node [draw,red,fit to tree] {};}
[DP
[ book-ACC, name=book, triangle ] ]
[V\\buy, name=V] ]
[\emph{v}, name=v ] ] ]
[T, name=T ] ]
\node at (dots)[above=5ex]{{\bf CP-phase}};
\node at (VP)[below=17ex]{{\bf VP-phase}}; name=VPnod
\end{forest}
\end{exe}
这给了我以下错误信息:
./divide with zero.tex:39: Package PGF Math Error: You asked me to calculate `1
/0.0', but I cannot divide any number by zero.
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.39 \end{forest}
但是,如果我将 vP 下的空节点更改为任何内容,错误就会消失。
答案1
我已使用 @Jason 链接的问题中的注释来编辑代码以解决问题。下面的代码解决了 pgf 的问题,但在空白节点处留下了一些空白,分支几乎连接在那里。在特定环境(forest
而不是整个文档)本地使用以下命令,您仍然可以对文档中的所有其他树使用 nice empty nodes 命令。
calign=fixed edge angles ,delay={where content={}{shape=rectangle, inner sep=0pt, outer sep=0pt ,for parent={for children={anchor=north}}}{}}
\begin{exe}
\ex
\begin{forest} qtree, calign=fixed edge angles ,delay={where content={}{shape=rectangle, inner sep=0pt, outer sep=0pt ,for parent={for children={anchor=north}}}{}},
[\ldots, for descendants={l=0}, name=dots , tikz={\node [draw,green,inner sep=12pt, fit=(V)(dots)(book)(Erel)(v)(T)] {};}
[ \emph{v}P, s sep=22pt
[DP
[Erel, triangle, name=Erel ] ]
[ {}, s sep=30pt
[VP, name=VP, tikz={\node [draw,red,fit to tree] {};}
[DP
[ book-ACC, name=book, triangle ] ]
[V\\buy, name=V] ]
[\emph{v}, name=v ] ] ]
[T, name=T ] ]
\node at (dots)[above=5ex]{{\bf CP-phase}};
\node at (VP)[below=13ex]{{\bf VP-phase}}; name=VPnod
\end{forest}
\end{exe}
这是最终结果。如你所见,空白节点分支到 VP,五与母节点的分支没有完全连接五磷
编辑:有关同一类型问题的最新帖子,请参阅这里。此解决方案处理示例编号,并将其设置为与树中的最高节点对齐,而不是与节点ldots
对齐