6

Here is a code found in this post.

\documentclass{article}

\usepackage[edges]{forest}

\begin{document}

\begin{forest}                      
forked edges,                       % Tree style 
for tree={grow=0, s sep=0pt, 
edge= thick,  
anchor=base west,  
font=\strut\footnotesize\sffamily},
                                    %
[,phantom                           % Paranormal root  (BOO!)
                                    %  
[aaaa                               % Real branch   
    [bbb,tier=b, 
        [eeeeeeeeeeee, tier=c 
            [fff, tier=d]]] 
    [ccc 
        [gg, tier=c] 
        [hhh, tier=c]] 
    [ddddddddd 
        [iii, tier=c]]]                          
                                    %
[One,for tree={color=gray,no edge}  % Ethereal branch 
[Two, tier=b                            
[Three,  tier=c                       
[Four, tier=d]]]]                   
                                    %  
]                                   % Closing poltergeist
                                    %
\end{forest}

\end{document}

I would like to adapt the code above to obtain what I have added by hand in red. Is it possible?

enter image description here

1 Answer 1

7

Use calign=child, calign child=-1. Child number -1 is the last child.

enter image description here

\documentclass{article}

\usepackage[edges]{forest}

\begin{document}

\begin{forest}                      
forked edges,                       % Tree style 
for tree={grow=0, s sep=0pt, 
edge= thick,  
anchor=base west,  
font=\strut\footnotesize\sffamily},
                                    %
[,phantom                           % Paranormal root  (BOO!)
                                    %  
[aaaa, calign=child, calign child=-1                               % Real branch   
    [bbb,tier=b, 
        [eeeeeeeeeeee, tier=c 
            [fff, tier=d]]] 
    [ccc, calign=child, calign child=-1 
        [gg, tier=c] 
        [hhh, tier=c]] 
    [ddddddddd 
        [iii, tier=c]]]                          
                                    %
[One,for tree={color=gray,no edge}  % Ethereal branch 
[Two, tier=b                            
[Three,  tier=c                       
[Four, tier=d]]]]                   
                                    %  
]                                   % Closing poltergeist
                                    %
\end{forest}

\end{document}

You can also place the calign options in the for tree.

\documentclass{article}

\usepackage[edges]{forest}

\begin{document}

\begin{forest}                      
forked edges,                       % Tree style 
for tree={grow=0, s sep=0pt, 
edge= thick,  
anchor=base west,  
font=\strut\footnotesize\sffamily,
calign=child, calign child=-1},
                                    %
[,phantom                           % Paranormal root  (BOO!)
                                    %  
[aaaa                               % Real branch   
    [bbb,tier=b, 
        [eeeeeeeeeeee, tier=c 
            [fff, tier=d]]] 
    [ccc 
        [gg, tier=c] 
        [hhh, tier=c]] 
    [ddddddddd 
        [iii, tier=c]]]                          
                                    %
[One,for tree={color=gray,no edge}  % Ethereal branch 
[Two, tier=b                            
[Three,  tier=c                       
[Four, tier=d]]]]                   
                                    %  
]                                   % Closing poltergeist
                                    %
\end{forest}

\end{document}
0

You must log in to answer this question.

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