2

I have the following code sample with the "forest"-environment.

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

\begin{document}
\begin{forest}
for tree={grow=0, l=5cm, anchor=west, calign=center, child anchor=west, tier/.pgfmath=level() }
    [ Zuverlaessigkeit 
        [ Bedrohung, edge label={node[midway,left] {Gefaehrdet}}
            [ Entwurfsfehler ]
            [ Herstellungsfehler ]
            [ Betriebsfehler ]
        ]
        [ Eigenschaften, edge label={node[midway,below] {Definiert}} 
            [ Verfuegbarkeit ]
            [ Bestaendigkeit ]
            [ Sicherheit ]
            [ Integritaet ]
            [ Instandhaltbarkeit ]
        ]
        [ Behelfsmittel, edge label={node[midway,left] {Schuetzt}}
            [ Fehlerpraevention ]
            [ Fehlertoleranz ]
            [ Fehlervorausberechnung ]
            [ Fehlerbeseitigung ]
        ]
    ]
\end{forest}
\end{document}

It should look something like this: enter image description here

I have the problem that my node "Eigenschaften" doesn't align with the node "Zuverlaessigkeit". I want it to be on the same level. Does anybody have an idea? Thank you in advance!

2
  • Try l=2cm, calign=fixed angles.
    – user121799
    Commented Sep 21, 2018 at 19:43
  • Please see also this answer.
    – user121799
    Commented Sep 21, 2018 at 21:01

2 Answers 2

2

like this:

enter image description here

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

\begin{document}
\begin{forest}
for tree={grow=0, l=5cm, anchor=west, calign=center, child anchor=west, tier/.pgfmath=level() }
    [ Zuverlaessigkeit
        [ Bedrohung, edge label={node[midway,left] {Gefaehrdet}}
            [ Entwurfsfehler ]
            [ Herstellungsfehler ]
            [ Betriebsfehler ]
        ]
        [ Eigenschaften,
          before computing xy={s/.average={s}{siblings}}, % <---
          edge label={node[midway,below] {Definiert}}
            [ Verfuegbarkeit ]
            [ Bestaendigkeit ]
            [ Sicherheit ]
            [ Integritaet ]
            [ Instandhaltbarkeit ]
        ]
        [ Behelfsmittel, edge label={node[midway,left] {Schuetzt}}
            [ Fehlerpraevention ]
            [ Fehlertoleranz ]
            [ Fehlervorausberechnung ]
            [ Fehlerbeseitigung ]
        ]
    ]
\end{forest}
\end{document}
1

Just spelling out my comment. No manual adjustment.

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

\begin{document}
\begin{forest}
for tree={grow=0,l=1.2cm,anchor=west, calign=fixed angles, child anchor=west, tier/.pgfmath=level() }
    [ Zuverlaessigkeit 
        [ Bedrohung, edge label={node[midway,left] {Gefaehrdet}}
            [ Entwurfsfehler ]
            [ Herstellungsfehler ]
            [ Betriebsfehler ]
        ]
        [ Eigenschaften, edge label={node[midway,below] {Definiert}} 
            [ Verfuegbarkeit ]
            [ Bestaendigkeit ]
            [ Sicherheit ]
            [ Integritaet ]
            [ Instandhaltbarkeit ]
        ]
        [ Behelfsmittel, edge label={node[midway,left] {Schuetzt}}
            [ Fehlerpraevention ]
            [ Fehlertoleranz ]
            [ Fehlervorausberechnung ]
            [ Fehlerbeseitigung ]
        ]
    ]
\end{forest}
\end{document}

enter image description here

You must log in to answer this question.

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