5

I need to draw an arrow, using \draw[semithick,->] (t)..controls +(south west:5) and +(south:5) .. (wh);.

I want the arrow to connect e3 at the bottom of the following tree to the single e3 occurring higher up in it:

    \documentclass[12pt,a4paper]{article}   
    \usepackage{tikz-qtree}
    \usepackage{tikz-qtree-compat}
    \usepackage{ulem}

    \begin{document}

     \begin{tikzpicture}
\Tree [.{$<$t$_{1}$,\hspace{0.1cm} \\$\lbrack$ \hspace{0.3cm} $\rbrack$, $\lbrack$ \hspace{0.3cm} $\rbrack$ $>$} [.{$<$(e$_{3}$ $\rightarrow$ t$_{1}$) $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$} \node(wh){something} ;]
[.{$<$(e$_{3}$  $\rightarrow$ t$_{1}$), \hspace{0.1cm} \\$\lbrack$ e$_{2}$ $\rbrack$, \hspace{0.1cm} \\$\lbrack$ \hcancel{e$_{3}$}
 \thinspace $\rbrack$ $>$ } [.{e$_{3}$}  ]
[.\node[draw]{{$<$t$_{1}$, \hspace{0.1cm} \\$\lbrack$ e$_{2}$ $\rbrack$, \hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$ }}; 
[.\node[draw]{e$_{2}$ }; ]
[.{$<$(e$_{2}$  $\rightarrow$ t$_{1}$), \hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$} [.{$<$(e$_{3}$ $\rightarrow$ e$_{2}$  $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ $\emptyset$ $\rbrack$ $>$}  {$<$(e$_{3}$ $\rightarrow$ e$_{2}$  $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ $\emptyset$ $\rbrack$ $>$} ]
[.\node[draw]{e$_{3}$ }; 
[. e$_{3}$; ] ] ] ] ] ] ] ]
\end{tikzpicture}

\end{document}

How can I do this?

  • 1
    Did you forget a } somewhere? I can't compile this code. – Alenanno Jun 17 '15 at 9:17
  • It works for me... strange – user65526 Jun 17 '15 at 9:50
  • 1
    I also can't get the MWE to compile (an undefined control sequence error). It looks like there are several places whether _ is used outside math mode. I don't see a reason to keep going in and out of math mode within your type specifications. I would recommend posting a much simpler MWE (or at least a screenshot of the output you get iwth the one you posted) so we can see what's going on with the arrow. The code snippet for the arrow looks fine -- you should just be able to put that after the last bracket in the tree and before \end{tikzpicture}. – Jason Zentz Jun 17 '15 at 12:17
  • How about this code instead – user65526 Jun 17 '15 at 12:59
3

Simply use \nodes with names for those elements and then use the names to connect them:

\documentclass[12pt,a4paper]{article}   
    \usepackage{tikz-qtree}
    \usepackage{tikz-qtree-compat}
    \usepackage{ulem}

\def\hcancel#1{}% provissional definition; delete this line in your actual code

    \begin{document}

     \begin{tikzpicture}
\Tree 
[.{$<$t$_{1}$,\hspace{0.1cm} \\$\lbrack$ \hspace{0.3cm} $\rbrack$, $\lbrack$ \hspace{0.3cm} $\rbrack$ $>$} 
  [.{$<$(e$_{3}$ $\rightarrow$ t$_{1}$) $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$} \node(wh){something} ;
  ]
  [.{$<$(e$_{3}$  $\rightarrow$ t$_{1}$), \hspace{0.1cm} \\$\lbrack$ e$_{2}$ $\rbrack$, \hspace{0.1cm} \\$\lbrack$ \hcancel{e$_{3}$}
 \thinspace $\rbrack$ $>$ } 
    [. \node (ue) {e$_{3}$};  ]
    [.\node[draw]{{$<$t$_{1}$, \hspace{0.1cm} \\$\lbrack$ e$_{2}$ $\rbrack$, \hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$ }}; 
      [.\node[draw]{e$_{2}$ }; ]
      [.{$<$(e$_{2}$  $\rightarrow$ t$_{1}$), \hspace{0.1cm} \\$\lbrack$ e$_{3}$ $\rbrack$ $>$} 
        [.{$<$(e$_{3}$ $\rightarrow$ e$_{2}$  $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ $\emptyset$ $\rbrack$ $>$}  {$<$(e$_{3}$ $\rightarrow$ e$_{2}$  $\rightarrow$ t$_{1}$),\hspace{0.1cm} \\$\lbrack$ $\emptyset$ $\rbrack$ $>$} 
        ]
        [.\node[draw]{e$_{3}$ }; 
          [. \node (le) {e$_{3}$}; ] 
        ]
      ]
    ]
  ]
]
\draw[semithick,->] 
  (le)..controls +(south west:5) and +(south:5) .. (ue);
\end{tikzpicture}

\end{document}

enter image description here

Since I didn't know where the \hcancel command came from, I provided a simple definition

\def\hcancel#1{}

to make the example code compilable. Remove that definition in your actual code.

| improve this answer | |

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.