# Shifting a node over another node in forest

I have the following tree, which is non-projective and this is where the problems start =;-). In order to be able to draw it at all, I had to use a lot of phantom nodes and no edge declarations, but at least it worked except one thing. I do not know how to shift the second Subj node over the ob. Is this possible somehow?

\documentclass{article}

\usepackage{forest}

% The following code fixes the size of triangles for examples with translations. The specification
% ",delay=with translation" at the leaves is important to make this work.
% http://tex.stackexchange.com/questions/167978/smaller-roofs-for-forest/205311#205311
\forestset{
with translation/.style={
l sep=0,inner xsep=0,
append translation/.expanded/.wrap pgfmath arg={\gettranslation{##1}}{content},
content/.expanded/.wrap pgfmath arg={\gettext{##1}}{content},
},
append translation/.style={append={[#1,no edge,l=0,inner xsep=0,inner ysep=0,outer ysep=0,before computing xy={l-=5pt}]}}
}

\def\gettext#1{\gettextA#1;;\endget}
\def\gettextA#1;#2;{\removesep#1;}
\def\gettranslation#1{\gettranslationA#1;;\endget}
\def\gettranslationA#1;#2;{\removesep#2;}
\def\removesep#1;#2\endget{#1}

% a specific style that specifies the word tier: all nodes that do not have any children
% to do: make this style default and change all other figures explicitely as is described here:
% http://tex.stackexchange.com/questions/167983/getting-rid-of-a-default-where-specification
\forestset{
dg edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=bottom},
where n children=0{tier=word,edge=dotted,calign with current edge,delay=with translation}{}
},
%
% Adjunct edges as suggested by Engels, 1977
% http://tex.stackexchange.com/questions/204770/defining-a-special-edge-style-for-connecting-nodes-in-forest/204819#204819
(!u.parent anchor)--(.child anchor)-- +(0,#1)\forestoption{edge label};}},
%
}

\begin{document}

\begin{forest}
dg edges
[V, l sep+=6pt
[kl{\"a}rt;resolves]
[Subj
[dass;that]
[hidden, phantom
[ob;whether, name=ob, no edge] ]
[, phantom
[N, name=n1, no edge [Peter;Peter]]]
[, phantom
[N, name=n2, no edge [Klaus;Klaus]]]
[V, name=v1
[kommt;comes]]]
[Subj,name=subj2,s sep=-1cm
[V, name=v2
[spielt;plays]]]]
\draw[dotted] (subj2.south)--(ob.north);
\draw (v1.south)--(n1.north);
\draw (v2.south)--(n2.north);
\end{forest}

\end{document}


PS: I do not know why comes is so high, that does not happen with Linux Libertine ...

• Try adding some text depth and text height in append translation/.style to solve the problem with comes alignment. – Ignasi Nov 6 '14 at 10:32
• About comes. Don't create an extra node, use option align and separate lines by \\. This definition of with translation does the trick: \forestset{with translation/.style={inner xsep=0,align=center,content/.expanded/.wrap pgfmath arg={\gettext{##1}\noexpand\\\gettranslation{##1}}{content}}} (Actually, if you are fine with using \\ in the tree code, you could dispense with \gettranslation and \gettext macros alltogether.) – Sašo Živanović Dec 11 '14 at 18:47
• @SašoŽivanović That's really helpful. For some reason, it never occurred to me that I could use both .expanded and .wrap pgfmath arg. (This is TiKZ ignorance, I think. As is the fact that I'm never sure whether I want # or ##!) – cfr Dec 27 '14 at 23:28

If you want to have the second subject on the "ob", then its maybe best to restructure the tree. I placed the subjects on top of their first part and used the hidden nodes and explicitly drawn edges to link them to their later parts. Lets hope the structure is still the same :) albeit the word order seems to be off for the German version...

I also added struts to the English words to make them all the same hight independent from their ascent and decent (not in the figure).

\begin{forest}
dg edges
[V, l sep+=6pt
[kl{\"a}rt;resolves]
[Subj, name=s1
[dass;that]]
[Subj, name=s2
[ob;whether]]
[hidden, phantom
[hidden, phantom
[N, name=n1
[Peter;Peter]]]
[hidden, phantom
[N, name=n2[Klaus;Klaus]]]
[V, name=v1
[kommt;\strut comes]]]
[hidden, phantom
[V, name=v2
[spielt;plays]]]
]
\draw (s1.south)--(v1.north);
\draw (s2.south)--(v2.north);
\draw (v1.south)--(n1.north);
\draw (v2.south)--(n2.north);
\end{forest}


• Thanks a lot! This is of course much better, than shifting nodes around. The order of the words is off, since this is an example for a structure that should not exist. – Stefan Müller Nov 6 '14 at 14:28
• @StefanMüller Please consider accepting Harald's solution if it answered your question. – cfr Dec 17 '14 at 22:46