# Forest: Create phantom node which takes up no space?

I want to create a phantom node which takes up no space at the top of the tree, for alignment purposes, so that the first labeled node of the tree lines up with the example number. Setting l sep=0pt is obviously not enough. What else do I need to set to achieve this?

MWE:

\documentclass{article}

\usepackage[linguistics]{forest}
\usepackage{expex}

\begin{document}

\ex\begin{forest}
[, phantom
[{Jane is ...}, tier=words]
[AjP
[Specifier
[very, tier=words]
]
[Aj'
[Aj
[fond, tier=words]
]
[PP
[{of Cheetah}, roof, tier=words]
]
]
]
]
\end{forest}\xe

\end{document}


• What versions of forest and expex are you using? This doesn't line up with the example number at all for me, i.e., the tree ends up slightly above the (1). (TL 2017) – Alan Munn Jul 12 '17 at 13:55
• Untested, because I can't reproduce your problem with the current version of forest: Try adding ,baseline to your AjP node. – Alan Munn Jul 12 '17 at 14:55
• @AlanMunn There's something very odd about what the current version does here, isn't there? baseline should be applied to the root by default, so why does it seem not to be? – cfr Jul 12 '17 at 23:51
• @cfr Yes. I've already emailed Sašo about it. – Alan Munn Jul 13 '17 at 0:41

I cannot reproduce your problem with the current version of forest. But with the current version, you can add baseline to any node to make that node the baseline of the tree.

(Unrelated linguistics comment: "specifier" is the name of a syntactic position, not a syntactic category or node in the tree, and should generally never appear in the tree.)

\documentclass{article}

\usepackage[linguistics]{forest}
\usepackage{expex}

\begin{document}

\ex
\begin{forest}
[,phantom,
[{Jane is ...}, tier=words]
[AjP,baseline
[Specifier
[very, tier=words]
]
[Aj'
[Aj
[fond, tier=words]
]
[PP
[{of Cheetah}, roof, tier=words]
]
]
]
]
\end{forest}
\xe

\end{document}


• That worked for me. To answer your above question, expex says 2014/03/10 v5.0b; forest 2016/03/04 v2.0.2. – Jipí Jul 12 '17 at 16:22
• @Jipí That makes sense. There were some changes made to the processing of phantom nodes in v. 2.0.3. The current version is 2.1.4. – Alan Munn Jul 12 '17 at 16:26
• @Jipí 2.0.2 is buggy. It would be better to use at least the last version prior to 2.1, if for some reason you don't want to update to the current version. – cfr Jul 12 '17 at 23:46
• Thanks for this unrelated linguistic comment! This is all over the place in linguistic literature. – Stefan Müller Aug 12 at 15:25
• @StefanMüller well just because people do it, doesn't mean it's right... :) There also shouldn't be a line between the word and the category of the terminal node, and people do that too. (I didn't mention that on this answer, though.) – Alan Munn Aug 12 at 15:41

Prior to v2.0.3, Forest would set the baseline node (the node whose anchor will be aligned to baseline) whenever the baseline key was used, even if it was used on a phantom node that was not drawn by TikZ. One would expect that this would result in a TikZ error, but it did not.

Once a node was created in TikZ, it's name persists even outside of the group (I guess this could be considered a bug), with the "node" positioned at (0,0), like here:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node(foo){};
\end{tikzpicture}

\begin{tikzpicture}
\draw[->] (-1,1) -- (foo.center) -- (1,1);
\end{tikzpicture}

\end{document}


Combine the above with the fact that Forest reuses node names (the root is usually named node@2 by default) and you get the problem. If you set the baseline node to root (like the linguistics library does) and make root phantom (as is commonly done to typeset side-by-side trees), TikZ effectively sets the baseline to y=0. The result is shown by OPs example.

Now, Forest 2.0.3 (where trouble introduced by draw tree method was fixed) got clever and stopped instructing TikZ to set baseline node to phantom nodes (more precisely, any node that is not drawn). Thus, starting with this version, the baseline is not set for side-by-side linguistic trees anymore. The result, as promised by TikZ manual, is that "the lower end of the picture is put on the baseline of the surrounding text", like in the following example. (The nodes are drawn to better see the alignment.)

\documentclass{article}

\usepackage[linguistics]{forest}
\usepackage{gb4e}

\begin{document}
\begin{exe}
\ex\begin{forest}
for tree=draw
[,phantom
[VP[V][DP]]
[VP[V][DP]]
]
\end{forest}
\end{exe}
\end{document}


This is what we get when compiling the above code with Forest v2.0.3 - v2.1.4.

To be absolutely clear: I consider this the expected behaviour. However, this does not mean it is the desired behaviour ... and this is why the linguistics library of v2.1.5 tries to be smarter: rougly speaking, it sets the baseline to the "first non-phantom node". In our example, that's the left VP, so we get:

(Temporary remark: Forest 2.1.5 is already submitted to CTAN and also available on GitHub.)

Now, admittedly, in OP's example, all this doesn't help at all, as "the first non-phantom node" resolves to Jane is .... The new baseline default in linguistics works for the common case of side-by-side trees; for anything out of ordinary, simply set baseline manually, as advised in Alan's answer.

• Off-topic: if you have time, could you visit the chat room? I left some notes/queries there, although I don't now remember what they were about .... – cfr Jul 14 '17 at 17:57

You do not really need a phantom root here at all. You just need to remove the edge for the first child and specify the alignment for the root.

\documentclass{article}

\usepackage[linguistics]{forest}
\usepackage{expex}

\begin{document}

\ex
\begin{forest}
where n children=0{tier=words}{}
[AjP, calign child=2
[Jane is \dots, no edge]
[Specifier
[very]
]
[Aj'
[Aj
[fond]
]
[PP
[of Cheetah, roof]
]
]
]
\end{forest}
\xe

\end{document}


• Although this gets the tree right, it's linguistically abominable, since you've made the Jane is ... fake daughter of AjP which in reality it's abosolutely not. So conceptually the phantom node is probably better. :) – Alan Munn Jul 13 '17 at 4:53
• @AlanMunn Conceptually, I'd think it would be better to have the node outside the tree altogether e.g. tikz+={\node [anchor=mid east] at (!rF.mid -| current bounding box.west) {Jane is \dots};} or something. But I'm not a linguist. And the node isn't really a brother/sister of AjP either, is it? Though I see that that might be less objectionable. – cfr Jul 13 '17 at 12:01