forest - 获取类似格式化的特殊目录树

forest - 获取类似格式化的特殊目录树

这是在这个帖子

\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}

我想修改上面的代码以获得我手动添加的红色内容。可以吗?

在此处输入图片描述

答案1

使用calign=child, calign child=-1。孩子编号 -1 是最后一个孩子。

在此处输入图片描述

\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}

您还可以将calign选项放在中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}

相关内容