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'm using qtree and a tree with five children works perfectly:

\documentclass{standalone}
\usepackage{qtree}

\begin{document}

\Tree[.n 1 2 3 4 5 ]

\end{document}

Tree with 5 children

But when I add another node:

\documentclass{standalone}
\usepackage{qtree}

\begin{document}

\Tree[.n 1 2 3 4 5 6 ]

\end{document}

It prints a single 6. Checking the package documentation (warning: pdf) there seems to be a constraint of 5 children per node, and the reason eludes me.

What is the correct way to build such a tree?

share|improve this question
    
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Are you tied to qtree or can you consider an alternative? –  cfr Jun 8 at 22:44
2  
The reason for the restriction is basically that subtrees are built individually (i.e. there is code for 2, 3, 4, and 5 branching trees) rather than with an iterative or recursive algorithm. So the 5 branch limit is a hard limit. Given that linguistics trees (for which the package was developed) rarely, if ever require more branching than that, the hard limit is not a practical problem for linguists. –  Alan Munn Jun 8 at 23:17
    
@AlanMunn I should have remembered that since I hacked the 1- and 2- branch cases to support incremental visibility with beamer. (If a logician had written the package, it probably wouldn't have as many as 5!) –  cfr Jun 8 at 23:23

1 Answer 1

up vote 5 down vote accepted

If you do not object to using tikz, you have a number of more flexible options. tikz has a trees library but you will probably prefer something with a brackets-type syntax. tikz-qtree is one option. forest is another.

tikz-qtree

This option lets you keep using just the same syntax as qtree.

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

\begin{document}

\Tree
  [.n 1 2 3 4 5 6 ]

\end{document}

<code>tikz-qtree</code> tree with 6 children

forest

This option requires you to use a different syntax but it should nonetheless be rather familiar in many respects. The pay-off comes in the form of greater power and flexibility. While that's not needed for this example, it would be worth switching if you have more demanding trees to draw.

\documentclass{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
  [n
    [1]
    [2]
    [3]
    [4]
    [5]
    [6]
  ]
\end{forest}

\end{document}

<code>forest</code> tree with 6 children

Or perhaps:

\documentclass{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
  for tree={
    parent anchor=south,
    child anchor=north,
  }
  [n
  [1]
  [3]
  [3]
  [4]
  [5]
  [6]
  ]
\end{forest}

\end{document}

Another <code>forest</code> tree with 6 children

share|improve this answer
    
Great answer. I ended up using tikz-qtree as a drop-in replacement. The only feature missing is the automatic centering, but I can live with that. –  BoppreH Jun 8 at 23:17

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.