3

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
  • 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, 2011 at 22:50
  • @Alan: Thanks. Could you please help me with the tikz-qtree code? Aug 12, 2011 at 22:55

1 Answer 1

5

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

3
  • 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. Aug 13, 2011 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, 2011 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, 2011 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .