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.

The Qtree package is "a LaTeX package for drawing tree diagrams." Is it possible to draw simple graph-like diagrams with it, similar to the one depicted below? If not, should I resort to TikZ-qtree?

share|improve this question
2  
I don't think this is possible to do with qtree. (It is, after all qtree and not qgraph :-)) But it should be fairly easy to do in tikz-qtree I think. Since the basic syntax is the same, but tikz-qtree is much more powerful, I would start there. –  Alan Munn Aug 12 '11 at 22:50
    
@Alan: Thanks. Could you please help me with the tikz-qtree code? –  Sadeq Dousti Aug 12 '11 at 22:55
add comment

1 Answer

up vote 4 down vote accepted

Here's one solution.

\documentclass{article}
\usepackage{tikz-qtree}
\begin{document}

\begin{tikzpicture}[sibling distance=1cm, every node/.style={font=\sffamily}]

\Tree [.PSPACE 
      [.PP  
        [.BQP 
            [.BPP  \edge[white]; {} \edge; \node[xshift=2cm] (P) {P}; ] ] 
            [.\node (NP) {NP}; ]]]
\draw (P.north) -- (NP.south);

\end{tikzpicture}
\end{document}

Update

I've changed the method of moving the P node so that it is centred correctly. (Output image has been put in an \fbox to show the image edges.)

output of code

share|improve this answer
1  
+1, thanks. There's one minor problem, though: although the \edge[white]; command hides the edge, it prevents the diagram from correctly being centered on the page. –  Sadeq Dousti Aug 13 '11 at 0:27
1  
Removing \phantom{\hspace{4cm}} (leaving just empty braces) makes the positioning a whole lot better, though it's still very slightly off centre. –  Jake Aug 13 '11 at 0:43
1  
@Sadeq Jake's comment is right. I added the \phantom to centre the P relative to the PSPACE. You can remove it and add [xshift=2cm] to the P node. –  Alan Munn Aug 13 '11 at 1:37
add comment

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.