TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I am struggling on TikZ and it is really difficult to find options and solutions considering it is such a huge and comprehensive library.

What I actually would like to do is drawing, in a tree, a line that connects two adjacent sibling nodes. That's all.

What is the best solution?

share|improve this question
Just add a node name for each the nodes you want to connect and then use \draw to connect them. E.g. node (A) {XxX} and node (B) {YyY} will create nodes (A) and (B). Then at the end of your tree add \draw (A) -- (B); – Alan Munn Apr 2 '12 at 4:33
Gonna try this... – Andry Apr 2 '12 at 5:06
Post an answer man, you got this :) THANX a lot – Andry Apr 2 '12 at 5:20
\draw[dashed] (A) -- (B);? – Harish Kumar Apr 2 '12 at 6:09
Just have a look at the manual‌​. There is a chapter on Trees (18. Making Trees Grow). The second page of that chapter shows exactly what you want to do. It uses Alan's suggestion to do so (and Harish's to make it dashed). – Roelof Spijker Apr 2 '12 at 8:21
up vote 3 down vote accepted

It's sufficient to label any nodes that you want to connect and then simply use regular \draw commands to connect them. This is independent of what method you use to draw the trees. Below is a combined example using both regular TikZ tree methods or tikz-qtree methods (which provides a much less cumbersome syntax for most trees. In practice you would probably use one or the other.

% using regular TikZ tree methods
\node {A}
    child {node (B) {B}
        child {node {D}}
        child {node {E}}}
    child {node (C) {C}};
\draw[dashed] (B) -- (C);


% using tikz-qtree
\begin{tikzpicture}[sibling distance=3em]
\Tree [.A
         [.\node (B){B}; 
        [.D ]
            [.E ]
         [.\node (C) {C}; ] 
\draw[dashed] (B) -- (C);

output of code

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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