# Left and right branching in the same tree with tikz-qtree

Is it possible to have both right and left branching in the same tree with tikz-qtree? In the tree below I want the nodes F and G (and subsequently H and I) to be daughters of D, not E.

\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\usepackage{qtree}
\usepackage{tikz-qtree-compat}

\begin{document}

\begin{tikzpicture}

\Tree
[.A [.B ]
[.C [.D ]
[.E [.F ]
[.G [.H ] [.I ]
] ] ] ]

\end{tikzpicture}

\end{document}


• Welcome to TeX.SX! Have you looked at the forest package? It's also TikZ and made to build trees. It's a very powerful tool on that matter and can definetely do what you are asking! See this question on efficient ways of making trees tex.stackexchange.com/questions/113315/… – Guilherme Zanotelli Nov 24 '16 at 11:15
• @GuilhermeZ.Santos Since the problem here is converting a tree into the correct bracketed structure, forest would yield the same result with this tree. – Alan Munn Nov 24 '16 at 18:16
• @AlanMunn, true that!!! I totally disregard the code presented and automatically suggested forest beacuse it usually can manage things that tikz and qtree have difficult with. Shame on me... ;P – Guilherme Zanotelli Nov 24 '16 at 18:19

Of course you can. Each pair of square brackets is a node, and anything inside that pair will be dominated by that node. So this is just a matter of understanding how to turn a tree into a bracketed structure. It's helpful to use indenting to show the structure in your source code. I've removed the package qtree from your original code, since it's not needed.

\documentclass[12pt,a4paper]{report}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}

\begin{document}

\Tree
[.A [.B ]
[.C
[.D
[.F ]
[.G
[.H ]
[.I ]
]
]
[.E ]
]
]

\end{document}


To give you a better sense of the relation between the bracketing and the tree, here's your tree with brackets added to it. (This tree was created with forest, which is why it looks a little different.)