2

My problem is that the following tree produced with tikzpicture squeezes my nodes way too close together, as you can see in the picture below. I have been trying to use level distance to move the them further apart, but I can't seem to figure out the right way to use it.

Please excuse me if this seems simple. I'm still new to the world of Latex. To be honest, I'm quite proud I got this far.

\begin{tikzpicture}
\tikzset{grow'=right,level distance=60pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree[.{Gesamtes Lösungsgebiet} [.Hintergrundnetz ]
                                [.Airframe
                                    [.{Zelle und Tailboom} ]
                                    [.{Kufe und Streben (x2)} ]
                                    [.Hauptrotormast ]
                                    [.Leitwerke ]]
                                [.Rotoren
                                    [.{Hauptrotorblatt (x2)} ]
                                    [.{Heckrotorblatt (x2)} ]]]
\end{tikzpicture}

enter image description here

  • Welcome to TeX.SX! Could you pease turn your code fragment into a compilable minimal working example (MWE) by adding the documentclass as well as the relevnt packages? – leandriis Jul 7 at 19:52
  • 1
    You might want to increase the value of level distance. – leandriis Jul 7 at 19:53
  • Maybe I should have gone into more detail. If I increase the level distance, it changes the spacing between all levels, whereas I only want to change the first and second. – Georg Jul 7 at 20:01
4

In order to save some horizontal space, I have introduced a linebreak in the first node (As stated on page 3 of the tikz-qtree documentation this can be done using the align option.) I have also increased the value of level distance :

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}
\tikzset{grow'=right,level distance=100pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west, align=center}}
\Tree[.{Gesamtes\\ Lösungsgebiet} [.Hintergrundnetz ]
                                [.Airframe
                                    [.{Zelle und Tailboom} ]
                                    [.{Kufe und Streben (x2)} ]
                                    [.Hauptrotormast ]
                                    [.Leitwerke ]]
                                [.Rotoren
                                    [.{Hauptrotorblatt (x2)} ]
                                    [.{Heckrotorblatt (x2)} ]]]
\end{tikzpicture}
\end{document}

If you want to individually influence the level distance you can use \tikzset{level 1/.style={level distance=150pt}} see page 5 of the manual for more information.

  • thanks so much!! – Georg Jul 7 at 20:06
2

With forest is simple. With l sep you can define distance between levels independently from length of node text:

enter image description here

\documentclass{article}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
for tree = {
   grow' = 0,
anchor = west,
    l sep = 11mm,
    s sep = 3mm,
edge path = {\noexpand\path[\forestoption{edge}]
            (!u.east) --  (.west);
            },
        }
[Gesamtes Lösungsgebiet
    [Hintergrundnetz]
    [Airframe,
     before computing xy={s/.average={s}{siblings}}
        [Zelle und Tailboom]
        [Kufe und Streben (x2)]
        [Hauptrotormast]
        [Leitwerke]
    ]
    [Rotoren
        [Hauptrotorblatt (x2)]
        [Heckrotorblatt (x2)]
    ]
]
\end{forest}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.