# PGF Math error with blank node in forrest [duplicate]

\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 ] ]
[\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}


This gives me the following error message:

./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}


However if I change the empty node under vP to anything, the error is gone.

I have used the comments from the question linked to by @Jason to edit to code in order to solve the problem. The code below resolves the problem with pgf , but leaves some white space at the blank node, where the branches almost connects. Using the command below locally to the specific forest environment instead of the whole document you can still use the nice empty nodes command for all other trees in the document.

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 ] ]
[\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}


This is the final result. As you can see the blank node branching to VP and v is not fully connected to the branch from the mother node vP

EDIT: For a newer post relating to the same type of problem, see here. This solution takes care of the example number and sets it to align with the highest node in the tree instead of aligning with the ldots node

• As discussed in the comments under the question I linked to above, there does need to be some whitespace at the empty node. However, it's possible to use a negative value for inner ysep such that the gap is only visible when zoomed in really far. You will need to tweak this value to meet your needs -- the exact value will depend on font, font size, and the calign angle. – Jason Zentz May 7 '15 at 2:19
• A few other comments: (i) \bf is a deprecated command (use \textbf{} or {\bfseries} instead). (ii) You don't need to use the manual s sep values if you put fit=band on the nodes linearly adjacent to your boxes; that will ensure that there is only whitespace below those nodes. Personally, I would put fit=band on T too. (iii) I would recommend using calign=fixed edge angles and calign angle=60 within the scope of the if content={}{put them here} so that the lines are at appropriate angles, but only leading into and out of empty nodes. – Jason Zentz May 7 '15 at 2:43
• pretty nice empty nodes` should avoid the gap if it works as advertised. – cfr Aug 10 '16 at 0:28
• @JasonZentz The whitespace isn't critical. It is the size of the node and that it is a node, not a point, of course. But you can compensate automatically with v.2+ of Forest by using a style which draws the edges ever so slightly differently. This alters the angles very, very slightly, but I think the flaw is less visible than the gap. – cfr Aug 10 '16 at 0:30