6

Is there a "clever" way to draw curved lines between nodes without them to go all through the picture?

Here is my MWE :

\documentclass[11pt]{beamer}
\usepackage{ulem}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usetikzlibrary{positioning}
\usepackage{philex}

\begin{document}

\begin{frame}{Contraintes sur le mouvement}

\lb{}{La fille que j'aidais aime ce que tu détestes.}
\begin{center}
\begin{tikzpicture}[scale=.8]
\tikzset{every tree node/.style={align=center,anchor=north}}% to allow linebreaks

\Tree 
[.TP
[.DP 
    [.DP \edge[roof]; {La fille} ]
    [.\node(aidais){CP};  \edge[roof]; {que j'\fbox{aidais}} ] ]
[.T$'$  
[.\node(temps) {V\\\Huge\color{blue}?};  ]
[.VP 
[.DP \edge[roof]; {\sout{La fille...}} ] 
[.V$'$ 
%[.V \fbox{aime} ]
[.V \node(aime){\fbox{aime}}; ]
[.\node(détestes) {CP};  \edge[roof]; {ce que tu \fbox{détestes}} ] ] ] ] ]

\node (aidais2) [below=.7cm of aidais] {};
\node (aidais3) [right=.2cm of aidais2] {};
\node (temps2) [below=.3cm of temps] {};
\node (détestes2) [below=.7cm of détestes] {};
\node (détestes3) [right=.3cm of détestes2] {};

%\draw[semithick,->] (aidais3)..controls +( west:1) and +(east:1)..(temps2);
%\draw[semithick,->] (aime)..controls +( west:1) and +(east:1)..(temps2);
%\draw[semithick,->] (détestes3)..controls +( west:4) and +(east:4)..(temps2);
\draw[-latex] (aidais3.south) -- (temps.south west);
\draw[-latex] (aime.south) -- (temps.south east);
\draw[-latex] (détestes3.south) -- (temps.south);

\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

And here is the result : enter image description here

My question is : What code could draw the arrows to go 'around' the trees--not through it-- in order to reach the interrogation dot without them to cross each other ?

I've tried many different codes, but I don't really understand what I do, I change the options randomly to discover what they do, but I can't find a way do to it.

This is an example amoung many others, and I'm always embarrassed with these arrows. So I'm looking for a solution that could be generalized to similar examples (arrows on trees). And I don't even know where to look for in the tikz documentation.

Thanks for your help!

  • Also see TiKZ make lines connecting nodes have the same endpoints which is effectively a duplicate. – Alan Munn Feb 4 '14 at 23:31
  • Just a comment on your code: you might want to add a \strut inside your \fboxes so that they all are the same size (and possibly reduce the \fboxsep to .5pt. (Also your example lacks the relevant inputenc/fontenc combination to display the accented characters, although I assume this is just an oversight in the MWE. – Alan Munn Feb 4 '14 at 23:47
10

There are probably a lot of different ways to address this, but I find the following quite effective:

\draw[-latex] (aidais3.south) to[out=270,in=225,looseness=2] (temps.265);
\draw[-latex] (aime.south) to[out=270,in=270,looseness=2] (temps.280);
\draw[-latex] (détestes3.south) to[out=270,in=260,looseness=2] (temps.south);

screenshot

Note that I have specified the in angle and the out angle of the arrows. Note that I have also tweaked the final destination by using an angle of your temps node, as noted in Add more anchors to standard TikZ nodes. You can tweak the looseness parameter as you see fit :)

Here's the complete code:

% arara: pdflatex
\documentclass[11pt]{beamer}
\usepackage{ulem}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usetikzlibrary{positioning}
\usepackage{philex}

\begin{document}

\begin{frame}{Contraintes sur le mouvement}

\lb{}{La fille que j'aidais aime ce que tu détestes.}
\begin{center}
\begin{tikzpicture}[scale=.8]
\tikzset{every tree node/.style={align=center,anchor=north}}% to allow linebreaks

\Tree 
[.TP
[.DP 
    [.DP \edge[roof]; {La fille} ]
    [.\node(aidais){CP};  \edge[roof]; {que j'\fbox{aidais}} ] ]
[.T$'$  
[.\node(temps) {V\\\Huge\color{blue}?};  ]
[.VP 
[.DP \edge[roof]; {\sout{La fille...}} ] 
[.V$'$ 
%[.V \fbox{aime} ]
[.V \node(aime){\fbox{aime}}; ]
[.\node(détestes) {CP};  \edge[roof]; {ce que tu \fbox{détestes}} ] ] ] ] ]

\node (aidais2) [below=.7cm of aidais] {};
\node (aidais3) [right=.2cm of aidais2] {};
\node (temps2) [below=.3cm of temps] {};
\node (détestes2) [below=.7cm of détestes] {};
\node (détestes3) [right=.3cm of détestes2] {};

%\draw[semithick,->] (aidais3)..controls +( west:1) and +(east:1)..(temps2);
%\draw[semithick,->] (aime)..controls +( west:1) and +(east:1)..(temps2);
%\draw[semithick,->] (détestes3)..controls +( west:4) and +(east:4)..(temps2);
\draw[-latex] (aidais3.south) to[out=270,in=225,looseness=2] (temps.265);
\draw[-latex] (aime.south) to[out=270,in=270,looseness=2] (temps.280);
\draw[-latex] (détestes3.south) to[out=270,in=260,looseness=2] (temps.south);

\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.