2

I am looking to make a tree where the angle of the edge to children is the same at every level. I am aware that this might cause nodes to overlap.

I want something that looks like this:

tree with constant children edge angles

But unfortunately my tree looks like this:

tree with different children edge angles

My tree uses this LaTeX:

\tikzset{every tree node/.style={minimum width=2em,draw,circle},
         blank/.style={draw=none},
         edge from parent/.style=
         {draw,edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}},
         level distance=1cm
}

\begin{tikzpicture}
\Tree [ .1 [ .2 \edge[blank]; \node[blank]{}; [ .4 \edge[blank]; \node[blank]{}; [ .5 \edge[blank]; \node[blank]{}; [ .6 \edge[blank]; \node[blank]{}; 7 ] ] ] ] 3 ]
\end{tikzpicture}

Help is appreciated

4
  • Welcome to TeX.SX! You could add something like level 1/.style={sibling distance=-1cm} to the options in the \tikset macro. Commented Nov 30, 2021 at 18:45
  • @JasperHabicht Thank you, unfortunately it does not work. I have tried setting multiple levels to specific sibling distances, but they only work for specific trees and not all
    – Tim
    Commented Dec 1, 2021 at 6:04
  • 1
    Do you need to use the tikz-qtree package? I have the feeling that it is easier to achieve what you want using a normal Tikz tree or maybe using the forest package. Your answer seems to support my feeling … Commented Dec 1, 2021 at 6:46
  • 1
    Thank you! Forest offers a much nicer syntax. I have added it to my answer
    – Tim
    Commented Dec 1, 2021 at 7:14

1 Answer 1

2

I was able to recreate the tree in the first image by using tikz \node instead of tikz-qtree \Tree:

\begin{tikzpicture}
\node[circle,draw]{1}
  child{node[circle,draw]{2} child[missing] child{node[circle,draw]{4} child[missing] child{node[circle,draw]{5} child[missing] child{node[circle,draw]{6} child[missing] child{node[circle,draw]{7}}} } } }
  child{node[circle,draw]{3}} ;
\end{tikzpicture}

tree with same angle for each child node

Edit: This can also be done using forest, which has a nicer syntax:

\begin{forest}
for tree={draw,circle,calign=fixed edge angles}
[1 [2 [,phantom] [4 [,phantom] [5 [,phantom] [6 [,phantom] [7 [,phantom] ]]]]] [3]]
\end{forest}

Thanks to @Jasper Habicht for the suggestion to use forest.

You must log in to answer this question.

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