Take the 2-minute tour ×
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.

I want to draw a tree like this:

tree with nodes connected

The closest I could get to this was the following code:

\documentclass{minimal}

\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}
\tikzset{level 1+/.style={level distance=2\baselineskip}}
\Tree[.IP NP
       [.VP [.\node(v){V}; [ \node(v1){}; ] ]
            NP 
            [.PP [.\node(p){P}; \node(p1){}; ]
                 NP ] 
       ]
]
\draw (v) -- (v1) -- (p1) -- (p);
\end{tikzpicture}


\end{document}

But this involves empty auxiliary nodes and the lines have some space in the middle. Is there a simpler way to do this? Are there options to \drawthat can do this?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You can use the orthogonal intersection node and a little manual shift.

\documentclass{standalone}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}
\tikzset{level 1+/.style={level distance=2\baselineskip}}
\Tree[.IP NP
       [.VP [.\node(v){V};]
            NP 
            [.PP [.\node(p){P};]
                 NP ] 
       ]
]
\draw (v) |-  ([yshift=-5mm]v |- p) -| (p);
\end{tikzpicture}


\end{document}

enter image description here

share|improve this answer
    
Thanks! What does the manual shift do? Does it shift a v |- pobject? –  Stefan Müller Dec 2 '12 at 18:18
    
@StefanMüller It finds the orthogonal intersection (going down from v vertically and going to p horizontally. Then shifts 5mm down. –  percusse Dec 2 '12 at 18:28

Your Answer

 
discard

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.