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?

  • 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? – M.S. Dousti Aug 12 '11 at 22:55

Here's one solution.


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

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



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

| 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. – M.S. 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

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.