Forest – How to Align Nodes Horizontally

forest

I am trying to build a horizontal tree using package forest, though I don't manage to get the nodes well aligned.
Here is an example and MWE:

\documentclass{article}
\usepackage{forest}
\begin{document}
    \begin{forest}
        for tree={
        calign=center,
        grow'=east, % tree direction
        parent anchor=east, child anchor=west, % edge anchors
        rounded corners, draw,
        }
        [A [B [C [D [E[F]]] [D' [E' [F']]] ]]]
    \end{forest}
    \begin{forest}
        for tree={
        calign=center,
        grow'=east, % tree direction
        parent anchor=east, child anchor=west, % edge anchors
        rounded corners, draw, 
        }
        [g [B [g [D [E[F]]] [D' [E' [F']]] ]]]
    \end{forest}
\end{document}

mwe

What I would like to get is something like in the first tree, while as you can see from the second one, the text in the nodes influences their alignment.

Best Answer

Set the text height and text depth explicitly such that all nodes have the same height and baseline no matter what the letter looks like.

enter image description here

\documentclass[border=1mm]{standalone}
\usepackage{forest}
\begin{document}
    \begin{forest}
        for tree={
        calign=center,
        grow'=east, % tree direction
        parent anchor=east, child anchor=west, % edge anchors
        rounded corners, draw,
        text height=1.4ex, text depth=0.2ex % <<<<<<<<<<<<<
        }
        [g [B [g [D [E[F]]] [D' [E' [F']]] ]]]
    \end{forest}
\end{document}
Related Question