拉伸 Tikz 树

拉伸 Tikz 树

我有一棵美丽的树,但我无法将它拉长。具体来说,我想增加第一个和第二个孩子与他们的孙子之间的距离。有什么建议吗?

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

\begin{document}


\begin{forest}
        for tree={
            thick,
            l sep=0.55cm,
            s sep=0.55cm,
            child anchor=west,
            parent anchor=east,
            grow'=east,
            draw,
            anchor=west,
            node options={draw,font=\sffamily},
            edge={semithick},
            align=center,
            node options={draw,font=\sffamily},
            edge={semithick},
            forked edges,
            where n children={11}{rotate=90, anchor=center}{},
            where n children=2{rotate=90, anchor=center}{},
            where n children=6{rotate=90, anchor=center}{},
            where n children=8{rotate=90, anchor=center}{},
        },
        %           edge path={
        %               \noexpand \path[\forestoption{edge}]
        %               (.child anchor) 
        %               -- +(-10pt,0) 
        %               |- (!u.parent anchor)
        %               \forestoption{edge label};
        %           },
        %           ver/.style={rotate=90, child anchor=north, parent anchor=south, anchor=center},
        %   }
        [Mother branch, 
        [First Child
        [Grand child []]
        [Grand child    []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        [Second Child
        [Grand child [ ]]
        [Grand child [] ]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        ]
    \end{forest}
\end{document}

答案1

你可以选择性地增加水平距离,例如

where level=2{l+=0.5cm,fork sep=8mm}{}, 

我还调整了fork sep光学元件。MWE:

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

\begin{document}


\begin{forest}
        for tree={
            thick,
            l sep=0.55cm,
            where level=2{l+=0.5cm,fork sep=8mm}{},         
            s sep=0.55cm,
            child anchor=west,
            parent anchor=east,
            grow'=east,
            draw,
            anchor=west,
            node options={draw,font=\sffamily},
            edge={semithick},
            align=center,
            node options={draw,font=\sffamily},
            edge={semithick},
            forked edges,
            where n children={11}{rotate=90, anchor=center}{},
            where n children=2{rotate=90, anchor=center}{},
            where n children=6{rotate=90, anchor=center}{},
            where n children=8{rotate=90, anchor=center}{},
        },
        [Mother branch, 
        [First Child
        [Grand child []]
        [Grand child    []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        [Second Child
        [Grand child [ ]]
        [Grand child [] ]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        ]
    \end{forest}
\end{document}

在此处输入图片描述

答案2

我猜你正在寻找类似这样的东西:

在此处输入图片描述

获得方法如下姆韦

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

\begin{document}
\begin{forest}
        for tree={
            grow'=east,
            anchor=west,
            node options={draw, thick, font=\sffamily},
            edge={semithick},
            forked edges,
            l sep=6mm,
            s sep=4mm,
            fork sep = 2.5mm,           % new, distance from parent to branching point
            where level=1{s sep=1mm}{}, % new
            where level=2{}{rotate=90, anchor=center} % new
        },
        [Mother branch,
        [First Child
        [Grand child []]
        [Grand child    []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        [Second Child
        [Grand child [ ]]
        [Grand child [] ]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        [Grand child []]
        ]
        ]
    \end{forest}
\end{document}

相比您的变化姆韦用 表示% new。我还删除了 mwe 中所有重复的代码行。

相关内容