2

I am using the qtree package to try to render a tree.

\Tree [.+ [.+ 1 [.+ 2 3 ] ]
          \qroof{\Tree [.+ [.+ 2 4 ] 6 ] \qquad \Tree [.+ [.+ 3 5 ] 7 ] }.A
      ]

The code renders the following image. Note that the left ([.+ 1 [.+ 2 3 ] ]) subtree is completely absent.

enter image description here

Am I doing something wrong or could this be a qtree bug?

1
  • Welcome to TeX.se. It's always more helpful to post a complete compilable example (like the one in my answer) rather than just a code fragment as you have done here.
    – Alan Munn
    Nov 23, 2021 at 1:30

1 Answer 1

1

The qtree package is very old, and for most purposes there are better packages available. But the qtree \Tree command is not intended to be embedded in the way that you did in your example code, so I wouldn't call the behaviour you are seeing a bug. In fact, most of the tree drawing packages will not allow you to embed one tree inside the other in this way.

If you want to achieve the effect of embedding the trees, you could use \savebox to precompile the embedded trees. I've shown a solution using that method with qtree.

Personally, however, I would recommend using the forest package and drawing the roofed node manually rather than embedding trees (which isn't possible with forest either.)

\documentclass{article}
\usepackage[linguistics]{forest}
\usepackage{qtree}
\newsavebox{\myA}
\newsavebox{\myB}
\begin{document}
\savebox\myA{\Tree [.+ [.+ 2 4 ] 6 ] }
\savebox\myB{\Tree [.+ [.+ 3 5 ] 7 ] }
\Tree [.+ [.+ 1 [.+ 2 3 ] ]
          \qroof{\usebox\myA\qquad\usebox\myB  }.A
      ]
\hfill
\begin{forest}
[+ [+ [1] [+ [2] [3] ] ]
           [A [+,name=A1 [+ [2] [4] ] [6] ]  [+,name=A2 [+ [3] [5] ] [7] ]
      ]]
\draw (A1.north)--(A2.north);
\end{forest}

\end{document}

output of code

You must log in to answer this question.

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