Hm, a tree doesn’t look right. What about chains?
We install two chains:
- Chain
sentence
goes to the right, sentence going base right
,
- Chain
verbs
goes up, verbs going above
.
On the sentence
chain we simply place the parts daß er das Lied
, wird
, haben
, singen
, können
, for items that have an Umlaut or an Eszett we assign a safe name without them (there are possible other solutions but those would make accessing those nodes harder). If we do not specify a \Name
in the \foreach
loop the \Item
text will simply be used.
The horizontal node distance .3333em
is set so that the nodes are placed as they would in a sentence, for this we also set the inner xsep
and the outer xsep
to zero. You can check this behavior by placing another node so that it overlaps with the sentence:
\node[anchor=text] at (sentence-begin.text) {da\ss\space er das Lied wird haben singen k\"onnen};
The vertical part of the node distance
, 1.5\baselineskip
, is chosen randomly, the inner ysep
is half the default size. The outer ysep
is also set to zero (we don’t have any drawn nodes).
The nodes of the vertical chain are automatically connected by the join
option (which uses the every join
style). The connections to the nodes in the sentence are also made in the second loop.
The special arc and line
style makes sure that the arcs are the size of a quarter circle with the biggest possible radius. An optional arc and line maximum
value can be assign, though.
If we set arc and line maximum
to a very small value, say 6pt
(the default for rounded corners
) we can mimic a basic -|
path with said rounded corners. No need for the calc
library and the let … in
stuff.
With arc and line maximum
set to zero we get the basic -|
path with sharp corners. Like above, we wouldn’t need calc
and those calculations.
Personally, I prefer the blue variant with a small rounded corners
radius.
Code
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{chains,calc}
\tikzset{
/pgf/arc and line maximum/.initial=+1000pt,
arc and line/.style={
to path={
let
\p{@end}=(\tikztotarget.north),
\p{@aux1}=($(\tikztostart)-(\p{@end})$),
\p{@start}=(node cs: name=\tikztostart, anchor={\x{@aux1} < 0pt ? +0 : +180}),
\n{@aux2}={min(\pgfkeysvalueof{/pgf/arc and line maximum},abs(\x{@start}-\x{@end}),abs(\y{@start}-\y{@end})-.1pt))}
in
{ [rounded corners=\n{@aux2}] -| (\tikztotarget) }
}},
special curve 0/.style={draw,->,arc and line},
special curve 1/.style={
special curve 0,
arc and line maximum=+6pt},
special curve 2/.style={
special curve 0,
arc and line maximum=+0pt},
every sentence and verb node/.style={
inner ysep=+.1667em,
outer ysep=+0pt},
sentence node/.style={
every sentence and verb node,
inner xsep=+0pt,
outer xsep=+0pt,
on chain=#1},
sentence node/.default=sentence,
verb node/.style={
every sentence and verb node,
on grid,
text depth=+0pt,
join,
on chain=#1},
verb node/.default=verbs
}
\begin{document}
\begin{tikzpicture}[
node distance=1.5\baselineskip and width(" ")*1pt,
start chain=sentence going base right,
start chain=verbs going above,
every join/.style={draw}
]
\foreach \Item/\Name in {da\ss\space er das Lied/dass,wird,haben,singen,k\"onnen/konnen}
\node [sentence node, alias=s-\Name] {\Item};
\chainin[on chain=verbs] (s-singen);
\foreach \Item/\Name in {k\"onnen/konnen,haben,wird} {
\node [verb node, alias=v-\Name] {\Item}
edge[special curve 2,green] (s-\Name)
edge[special curve 1,blue] (s-\Name)
edge[special curve 0] (s-\Name);
}
\end{tikzpicture}
\end{document}
Output
\node
is in no relation to the\Tree
. Could you also update the MWE which is neither compilable nor complete?