I'm using qtree to draw beutiful trees. Except that my tree is not compact and beautiful as expected.

More specifically, I would expect the nodes at the same depth to be at the same level. Of course I read the documentation, and I tried to add a nice !{\qbalance} in my last node, but it did't helped a lot.

Ugly latex tree

\Tree[.$\norm{X}$ [.$\cdots$    [.$\norm{X^1}$   [.$\cdots$ 
[.$\norm{x^1(1)}$ ] [.$\norm{x^1(2)}$ ]  ] [ .$\cdots$ [.$\norm{x^1(3)}$ ] 
[.$\norm{x^1(T_k)}$ [.$\cdots$ [.$\norm{x_1^1(T_k)}$ ] [.$\norm{x^2(2)}$ ] ] 
[.$\cdots$ [.$\norm{x_{d-1}^1(T_k)}$ ] [.$\norm{x_d^1(T_k)}$ ]  ]  ]]] 
[.$\norm{X^2}$ ] ]     [.$\cdots$  [.$\norm{X^3}$ [.$\cdots$ ] [.$\cdots$ ]] 
[.$\norm{X^K}$   [.$\cdots$ ] [.$\cdots$ ] ] ] ] 
  • please extend your code fragment to complete but small document. and reformat your code that it will be more readable.
    – Zarko
    Apr 4, 2018 at 23:08
  • not to have all code in one line. put (at least) each tree level in new line, for example. see similar questions and their answers in this site.
    – Zarko
    Apr 4, 2018 at 23:19
  • Sure Sure :D i thought it would have been done automatically bythe website... I dont think there are immediate useful ways of formatting a struture like that..
    – asdf
    Apr 4, 2018 at 23:24

1 Answer 1


The qtree package was designed for linguistic trees, and representing equal levels isn't really relevant for that. You would be better off using forest for your tree, since it does much better compaction and allows you to easily put nodes on equal levels.

Here's a version of your tree using forest.

\begin{forest}for tree={math content}
[\norm{X} [\cdots    [\norm{X^1}   [\cdots 
[\norm{x^1(1)} ] [\norm{x^1(2)} ]  ] [ \cdots [\norm{x^1(3)} ] 
[\norm{x^1(T_k)} [\cdots [\norm{x_1^1(T_k)} ] [\norm{x^2(2)} ] ] 
[\cdots [\norm{x_{d-1}^1(T_k)} ] [\norm{x_d^1(T_k)} ]  ]  ]]] 
[\norm{X^2} ] ]     [\cdots  [\norm{X^3} [\cdots ] [\cdots ]] 
[\norm{X^K}   [\cdots ] [\cdots ] ] ] ] 

output of code


You must log in to answer this question.

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