# Forest: Node alignment

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

\documentclass{article}

\usepackage{lscape}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}

\begin{document}

\tikzset{
block/.style={draw, fill=white!20, text width=2cm, text centered, rounded corners, minimum height=1.3cm},
line/.style={draw, very thick, color=black!80, -Stealth},
}

\begin{landscape}
\begin{forest}
arrow to/.style n args=4{%
delay={%
tikz+={%
\draw [every edge, line] () -- (!#1) node [above, midway] {#2};
},
},
!u.s sep+=30pt,
},
for tree={%
parent anchor=south,
child anchor=north,
calign=center,
grow=south,
block,
base=bottom,
edge={line},
l sep+=10pt,
where n children=0{tier=word}{},
font=\footnotesize
},
forked edges,
[Fehler Injektion
[Echte Hardware
[Physikalische Injektion
[Kontaktlose Injektion
]
[Kontakt Injektion
]
]
[Software
[Code Modifikation
]
[Laufzeit
]
]
]
[Imitierende Hardware
[Simulation
[Code Modifikation
]
[Laufzeit
]
]
[Emulation
[Rekonfi-\\guration
]
[Hilfsmech-\\anismen
]
]
]
]
\end{forest}
\end{landscape}

\end{document}


It should look something like this:

I have the problem, that my nodes don't align right on the level they should. The "Laufzeit" nodes should be a little bit lower, like the "Software", "Simulation" and "Emulation" nodes. Does anybody have an idea? Thank you in advance!

You only need to add anchor=center.

\documentclass{article}

\usepackage{lscape}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}

\begin{document}

\tikzset{
block/.style={draw, fill=white!20, text width=2cm, text centered, rounded corners, minimum height=1.3cm},
line/.style={draw, very thick, color=black!80, -Stealth},
}

\begin{landscape}
\begin{forest}
arrow to/.style n args=4{%
delay={%
tikz+={%
\draw [every edge, line] () -- (!#1) node [above, midway] {#2};
},
},
!u.s sep+=30pt,
},
for tree={%
parent anchor=south,
child anchor=north,
calign=center,
anchor=center,
grow=south,
block,
base=bottom,
edge={line},
l sep+=10pt,
where n children=0{tier=word}{},
font=\footnotesize
},
forked edges,
[Fehler Injektion
[Echte Hardware
[Physikalische Injektion
[Kontaktlose Injektion
]
[Kontakt Injektion
]
]
[Software
[Code Modifikation
]
[Laufzeit
]
]
]
[Imitierende Hardware
[Simulation
[Code Modifikation
]
[Laufzeit
]
]
[Emulation
[Rekonfi-\\guration
]
[Hilfsmech-\\anismen
]
]
]
]
\end{forest}
\end{landscape}

\end{document}


• Tex.stackexchange tells me not to write comments like "Thanks", but thank you, @marmot ! You answered another question of mine a few days ago, too. You are my hero! – AndiYo Sep 23 '18 at 23:57
• P.S. @AndiYo: marmot is the hero of several of us. :) – manooooh Sep 24 '18 at 0:13
• @manooooh I think you forgot that I lost my crystal ball. So I can no longer pretend to have some skills. :-( – user121799 Sep 24 '18 at 2:06
• But you have some native skills. – manooooh Sep 24 '18 at 2:35
• @manooooh Yes, I am really good at eating and hibernating. ;-) – user121799 Sep 24 '18 at 2:41