将一个节点移至森林中的另一个节点

将一个节点移至森林中的另一个节点

我有以下树,它是非投影的,这就是问题开始的地方 =;-)。为了能够完全绘制它,我不得不使用大量幻像节点和no edge声明,但至少除了一件事之外,它还是有效的。我不知道如何将第二个 Subj 节点移到 上ob。这有可能吗?在此处输入图片描述

\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
dg adjunct/.style={edge path={\noexpand\path[\forestoption{edge}]
(!u.parent anchor)--(.child anchor)-- +(0,#1)\forestoption{edge label};}},
%
dg adjunct/.default=6pt
    }


\begin{document}

\begin{forest}
dg edges
[V, l sep+=6pt
  [Adv, dg adjunct [deshalb;therefore] ]
  [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}

附言:我不知道为什么comes这么高,Linux Libertine 不会发生这种情况......

答案1

如果您想将第二个主题放在“ob”上,那么最好重新构建树。我将主题放在第一部分的顶部,并使用隐藏节点和明确绘制的边将它们链接到后面的部分。希望结构仍然相同 :) 虽然德语版本的词序似乎不对...

我还在英文单词中添加了支柱,使它们都具有相同的高度,而与它们的上升和下降无关(不在图中)。

\begin{forest}
dg edges
[V, l sep+=6pt
    [Adv, dg adjunct [deshalb;therefore] ]
    [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}

在此处输入图片描述

相关内容