2

There is a node whose children overlap with the neighbor node's children's edges in the MWE below (the children of nodes 10070070 and 10071027 with ZZZZ and YYYY for text).

The node Y seems to be pushed slightly left towards the node Z.

The node Z seems to be pushed slightly lower than it should be.

enter image description here

The only difference between node Z and the rest seems to be that its 2nd line of text has a new line in the middle, thus it has 4 lines whereas the rest have 3. The new line is unavoidable, as the whole Forest is machine-generated out of a hierarchical database and it is a business rule that certain strings have to have line breaks. I thought that minimum height=10ex should have taken care of that.

Is there any method to ensure that regardless of how many lines of text is inside a Forest node, as long as text is not making a node to expand vertically, it will be rendered uniform with the rest?

\documentclass[border=10pt]{standalone}
\usepackage{forest}

\begin{document}

\begin{forest} 
for tree={
    draw=black, align=center, l sep=4ex, parent anchor=south, child anchor=north,
    node options={font=\scriptsize, minimum width=14em, minimum height=10ex, rounded corners=1ex},
    edge path={
        \noexpand\path[\forestoption{edge}]
        (!u.parent anchor) -- +(0,-2ex) -| (.child anchor)\forestoption{edge label};
    },
    where n children=0{
        child anchor=west,
        edge path={
            \noexpand\path[\forestoption{edge}]
            ([xshift=-6em]!u.parent anchor) |- (.child anchor)\forestoption{edge label};
        },
        draw=red,for parent={
            parent anchor=south, l sep=-12em, grow'=east, calign=child edge, draw=blue          
        }
    }{}
}
[\textbf{AAAAAAAA AAAAAAAAAAA}\\AAAAAAAAA AAAA AAAAAAAAA\\AAAAAAAAAAA ,name=10005246
    [\textbf{AAAAA AAAAAAA}\\AAAAA AAAAAAA\\AAAAAAA ,name=10070085
        [\textbf{AAAAAAAA AAAAAAAA}\\AAAAAAAAA AAAAAAA\\AAAAAAA ,name=10070058
            [,phantom, minimum height=0ex]
            [\textbf{AAAAA AAAAAAAAA}\\AAAAAAAAA AAAAAAAAAAA\\AAAAAAA ,name=10071084]
        ]
        [\textbf{AAA AAAAAAA}\\AAAAAAAAAAAAA AAAA AAAAAAA\\AAAAAAA ,name=10070066
            [,phantom, minimum height=0ex]
            [\textbf{AAAA AAAAA}\\AAAAAAA AAAAAAAA\\AAAAAAA ,name=10070063]
            [\textbf{AAAA AAAAAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070107]
            [\textbf{AAAAAAA AAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070109]
            [\textbf{AAAA AAAAAAAA}\\AAAAAAA AAAAAAAA\\AAAAAAA ,name=10070119]
            [\textbf{AAAA AAAAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070122]
        ]
        [\textbf{AAAAAA AAAAAAA}\\AA AAAAAAA AAAAAAA\\AAAAAAA ,name=10070076
            [,phantom, minimum height=0ex]
            [\textbf{AAAAAAA AAAAAA}\\AAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070116]
            [\textbf{AAAAA AAAAAA}\\AAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070118]
        ]
        [\textbf{AAAAAA AAAAAAA}\\AAAAAAAAAA AAAAAAA\\AAAAAAA ,name=10070081
            [\textbf{ZZZZZ ZZZZZZ}\\ZZZZZZZ\\ZZZZZZZ ZZZZZZZ\\ZZZZZZZ ,name=10070070
                [,phantom, minimum height=0ex]
                [\textbf{ZZZZZZZ ZZZZZ}\\ZZZZ ZZZZZZZZ\\ZZZZZZZ ,name=10070117]
                [\textbf{ZZZZZZZ ZZZZZ}\\ZZZZ ZZZZZZZZ\\ZZZZZZZ ,name=10070121]
                [\textbf{AAAAA AAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10071097]
            ]
            % The children of the node below overlaps the children of the node above
            [\textbf{YYYYYY YYYYYYYY}\\YYYYYYYYYY YYYYYYY\\YYYYYYY ,name=10071027
                [,phantom, minimum height=0ex]
                [\textbf{YYYYY YYYYYYYY}\\YYYYYYYYYY YYYYYYYYYY\\YYYYYYY ,name=10070089]
                [\textbf{YYYYYYY Y YYYYYY}\\YYYYYYYYYY YYYYYYYYYY\\YYYYYYY ,name=10071317]
            ]
            [\textbf{AAAAAA AAAAAAAAAAAAAA}\\AAAAAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070059
                [,phantom]
            ]
            [\textbf{AAAA AAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070061
                [,phantom]
            ]
            [\textbf{AAAAAAA AAAAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070078
                [,phantom]
            ]
            [\textbf{AAAAAAA AAAAAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070091
                [,phantom]
            ]
            [\textbf{AAAAAAA AAAAAA }\\AAAAAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070120
                [,phantom]
            ]
        ]
        [\textbf{AAAAAAA AAAAAAAAA}\\AA AAAAAAA\\AAAAAAA ,name=10070098
            [,phantom, minimum height=0ex]
            [\textbf{AAAA AAAA}\\AAAAAAA\\AAAA AAAAAAAAAA\\AAAAAAA ,name=10070105]
            [\textbf{AAAAA AAAAAAAA}\\AA AAAAA\\AAAAAAA ,name=10070111]
            [\textbf{AAAAAAA AAAAAAAA}\\AA AAAAAAAAAA\\AAAAAAA ,name=10070115]
        ]
        [\textbf{AAAA AAAAAAAAA}\\AAAAAAAA AAAA AAAAAAAAAA\\AAAAAAA ,name=10011825
            [,phantom]
        ]
        [\textbf{AAAAAAAA AAAAA}\\AAAAAAAAAA{,} AAA\\AAAAAAA,name=10070079
            [,phantom]
        ]
    ]
]
\end{forest}
\end{document}

1 Answer 1

1

Add base=b so that the tabular content of the nodes is aligned on the baseline rather than the top:

\documentclass[border=10pt]{standalone}
\usepackage{forest}

\begin{document}

  \begin{forest}
    for tree={
      draw=black, align=center, l sep=4ex, parent anchor=south, child anchor=north,
      node options={font=\scriptsize, minimum width=14em, minimum height=10ex, rounded corners=1ex},
      edge path={
        \noexpand\path[\forestoption{edge}]
        (!u.parent anchor) -- +(0,-2ex) -| (.child anchor)\forestoption{edge label};
      },
      where n children=0{
        child anchor=west,
        edge path={
          \noexpand\path[\forestoption{edge}]
          ([xshift=-6em]!u.parent anchor) |- (.child anchor)\forestoption{edge label};
        },
        draw=red,for parent={
          parent anchor=south, l sep=-12em, grow'=east, calign=child edge, draw=blue
        }
      }{},
      base=b
    }
    [\textbf{AAAAAAAA AAAAAAAAAAA}\\AAAAAAAAA AAAA AAAAAAAAA\\AAAAAAAAAAA ,name=10005246
    [\textbf{AAAAA AAAAAAA}\\AAAAA AAAAAAA\\AAAAAAA ,name=10070085
    [\textbf{AAAAAAAA AAAAAAAA}\\AAAAAAAAA AAAAAAA\\AAAAAAA ,name=10070058
    [,phantom, minimum height=0ex]
    [\textbf{AAAAA AAAAAAAAA}\\AAAAAAAAA AAAAAAAAAAA\\AAAAAAA ,name=10071084]
    ]
    [\textbf{AAA AAAAAAA}\\AAAAAAAAAAAAA AAAA AAAAAAA\\AAAAAAA ,name=10070066
    [,phantom, minimum height=0ex]
    [\textbf{AAAA AAAAA}\\AAAAAAA AAAAAAAA\\AAAAAAA ,name=10070063]
    [\textbf{AAAA AAAAAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070107]
    [\textbf{AAAAAAA AAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070109]
    [\textbf{AAAA AAAAAAAA}\\AAAAAAA AAAAAAAA\\AAAAAAA ,name=10070119]
    [\textbf{AAAA AAAAA}\\AAAAA AAAAAAAA\\AAAAAAA ,name=10070122]
    ]
    [\textbf{AAAAAA AAAAAAA}\\AA AAAAAAA AAAAAAA\\AAAAAAA ,name=10070076
    [,phantom, minimum height=0ex]
    [\textbf{AAAAAAA AAAAAA}\\AAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070116]
    [\textbf{AAAAA AAAAAA}\\AAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070118]
    ]
    [\textbf{AAAAAA AAAAAAA}\\AAAAAAAAAA AAAAAAA\\AAAAAAA ,name=10070081
    [\textbf{ZZZZZ ZZZZZZ}\\ZZZZZZZ\\ZZZZZZZ ZZZZZZZ\\ZZZZZZZ ,name=10070070
    [,phantom, minimum height=0ex]
    [\textbf{ZZZZZZZ ZZZZZ}\\ZZZZ ZZZZZZZZ\\ZZZZZZZ ,name=10070117]
    [\textbf{ZZZZZZZ ZZZZZ}\\ZZZZ ZZZZZZZZ\\ZZZZZZZ ,name=10070121]
    [\textbf{AAAAA AAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10071097]
    ]
    % The children of the node below overlaps the children of the node above
    [\textbf{YYYYYY YYYYYYYY}\\YYYYYYYYYY YYYYYYY\\YYYYYYY ,name=10071027
    [,phantom, minimum height=0ex]
    [\textbf{YYYYY YYYYYYYY}\\YYYYYYYYYY YYYYYYYYYY\\YYYYYYY ,name=10070089]
    [\textbf{YYYYYYY Y YYYYYY}\\YYYYYYYYYY YYYYYYYYYY\\YYYYYYY ,name=10071317]
    ]
    [\textbf{AAAAAA AAAAAAAAAAAAAA}\\AAAAAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070059
    [,phantom]
    ]
    [\textbf{AAAA AAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070061
    [,phantom]
    ]
    [\textbf{AAAAAAA AAAAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070078
    [,phantom]
    ]
    [\textbf{AAAAAAA AAAAAAAAA}\\AAAA AAAAAAAA\\AAAAAAA ,name=10070091
    [,phantom]
    ]
    [\textbf{AAAAAAA AAAAAA }\\AAAAAAAAAA AAAAAAAAAA\\AAAAAAA ,name=10070120
    [,phantom]
    ]
    ]
    [\textbf{AAAAAAA AAAAAAAAA}\\AA AAAAAAA\\AAAAAAA ,name=10070098
    [,phantom, minimum height=0ex]
    [\textbf{AAAA AAAA}\\AAAAAAA\\AAAA AAAAAAAAAA\\AAAAAAA ,name=10070105]
    [\textbf{AAAAA AAAAAAAA}\\AA AAAAA\\AAAAAAA ,name=10070111]
    [\textbf{AAAAAAA AAAAAAAA}\\AA AAAAAAAAAA\\AAAAAAA ,name=10070115]
    ]
    [\textbf{AAAA AAAAAAAAA}\\AAAAAAAA AAAA AAAAAAAAAA\\AAAAAAA ,name=10011825
    [,phantom]
    ]
    [\textbf{AAAAAAAA AAAAA}\\AAAAAAAAAA{,} AAA\\AAAAAAA,name=10070079
    [,phantom]
    ]
    ]
    ]
  \end{forest}
\end{document}

Align on baseline

1
  • Great! This is documented on the pp. 15 and 26 of Forest manual, for those like me who missed it :)
    – ajeh
    Jun 25, 2014 at 12:32

You must log in to answer this question.

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