1

I'm not sure how the node function works for use in trees such as the one drawn by Gonzalo Medina in this post: Trees and arrows

I'd like to be able to create arrows going from different nodes to different nodes. I don't know what +(south west:5) and +(south:5) refer to, nor is it apparent that this is explained ANYWHERE with sufficient depth for my purposes (impressionistic remarks aside).

  • Re-apply your changes making sure you don't break the code formatting. If you want it to appear properly, select it all (the code only) and then click on the {} icon. – Alenanno Jun 18 '15 at 17:51
  • I've corrected the code for you. For large blocks of code, you can select the code and click on the {} icon or use Control-K. For inline code, if you are writing text control-K without anything selected will give you an opening and closing code quote. – Alan Munn Jun 18 '15 at 17:52
  • +(south west:5) means a point 5 units from here in the south-westerly direction. +(south:5) means 5 units due south. They are just polar coordinates. You could say e.g. +(-135:5) and +(-90:5). – cfr Jun 18 '15 at 18:05
  • Meanwhile I try to edit the code, and my editing clashes with editing of OP .. so this can be source of above mentioned problem with it. The code has some errors, so I suggest that OP look in it again, make it complete and ad in question as @Aleanno say in his comment. – Zarko Jun 18 '15 at 18:07
  • @user65526 Did you read my comment about code formatting? It's not too hard to get right. (OP = original poster, i.e., in this case, you) – Alan Munn Jun 18 '15 at 18:11
4

The arrow in your example is a cubic Bézier curve, so it has two control points that "guide" the direction of the curve. The position of the first control point is specified by +(south west:5) and the position of the second control point is specified by +(south:5). The following code, adapted from this answer to What type of curve is used by Tikz when I "bend" an edge?, shows these control points for the example you cited.

\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

\usetikzlibrary{decorations.pathreplacing,shapes.misc}
\tikzset{
    show control points/.style={
        decoration={show path construction, curveto code={
                \draw [blue, dashed]
                    (\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
                    node [at end, cross out, draw, solid, red, inner sep=2pt]{};
                \draw [blue, dashed]
                    (\tikzinputsegmentsupportb) -- (\tikzinputsegmentlast)
                    node [at start, cross out, draw, solid, red, inner sep=2pt]{};
            }
        },
        postaction=decorate
    },
}

\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,->,show control points] (le)..controls +(south west:5) and +(south:5) .. (ue);
\end{tikzpicture}

\end{document}

enter image description here

Curves in tikz

More explanation about curves in tikz can be found in the pgf manual, starting with section 2.4 on pp. 31-32. The formal definitions for the options and commands relevant for curves are in section 70.3 on pp. 753-756. There are also many examples of curves throughout the manual and elsewhere on this site.

Coordinates in tikz

You can use any of the tikz systems of specifying coordinates for the control points. These are described in section 11.1 on p. 120 in the manual. In the example you cited, the + means that the control point is specified relative to another point. The first control point is specified to be south west (down and to the left) of the beginning of the curve by 5. The second control point is specified to be south (down) of the end point of the curve by 5. The number is relative to the xy-coordinate system, which by default is measured in centimeters.

These control points could be equivalently specified as +(235:5) and +(270:5) if you prefer working with degrees rather than compass points. They can also be specified as +(-5,-5) and +(0,-5), which allows you to specify both the x- and y-coordinates for the control point for finer control over its position. I personally prefer using these (x,y) coordinates.

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.