改变树的方向

改变树的方向

请注意,以下树的代码位于: https://tex.stackexchange.com/questions/35526/tikz-tree-sibling-distance/35535

TikZ 树兄弟距离

但是,我希望它向右增长,如下图所示。请帮忙。谢谢。此致。

以下是上面引用的代码:

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage{forest}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{shadows}
\begin{document}
    \tikzset{
        my node style/.style={
            font=\small,
            top color=white,
            bottom color=blue!25,
            rectangle,
            rounded corners,
            minimum size=6mm,
            draw=blue!75,
            very thick,
            drop shadow,
            align=center,
        }
    }
    \forestset{
        my tree style/.style={
            for tree={
                parent anchor=south,
                child anchor=north,
                l sep+=5pt,
                my node style,
                edge={draw=blue!50, thick},
                edge path={
                    \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,-7.5pt) -| (.child anchor)\forestoption{edge label};
                },
                if n children=3{
                    for children={
                        if n=2{calign with current}{}
                    }
                }{},
                delay={if content={}{shape=coordinate}{}}
            }
        }
    }
    \centering
\begin{forest}
    my tree style
    [Paletizador
    [Inicialização\\de sistema
    [Sensor X]
    [Acção Y]
    ]
    [Sacos
    [
    [
    [Linha/Coluna
    [Garra]
    [Rodar Garra]
    [Acção Y2]
    ]
    [Euro Pallet]
    [{Disposição $xyz$}
    [{$x=?$}]
    [{$y=?$}]
    [{$z=?$}]
    ]
    ]
    ]
    ]
    [Sistema de despacho
    [Sensor de peso\\/contador]
    [Tapete rolante\\de saída]
    ]
    ]
\end{forest}

\end{document}

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

我把对儿童居中/定位的微调留给了你。

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[edges]{forest}
\usetikzlibrary{shadows}

\begin{document}
    \tikzset{
        my node style/.style={
            font=\small,
            top color=white,
            bottom color=blue!25,
            rectangle,
            rounded corners,
            minimum size=6mm,
            draw=blue!75,
            very thick,
            drop shadow,
            align=center,
        }
    }
    \forestset{
        my tree style/.style={
            for tree={grow=east,
                parent anchor=east, % <---
                child anchor=west,  % <---
                my node style,
        l sep=2em,
        forked edge,                % <---
        fork sep=1em,               % <---
        edge={draw=blue!50, thick},                
        if n children=3{for children={
                        if n=2{calign with current}{}}
                        }{},
%       delay={if content={}{shape=coordinate}{}},
        tier/.option=level,
                    }
        }
    }
\centering
    \begin{forest}
    my tree style
[Paletizador
    [Inicialização\\de sistema
        [Sensor X]
        [Acção Y]
    ]
    [Sacos,fit=band
        [Linha/Coluna
            [Garra]
            [Rodar Garra]
            [Acção Y2]
        ]
        [Euro Pallet,fit=band,before computing xy={s/.average={s}{siblings}}] % <---
        [{Disposição $xyz$}
            [{$x=?$}]
            [{$y=?$}]
            [{$z=?$}]
        ]
    ]
    [Sistema de despacho, 
        [Sensor de peso\\/contador]
        [Tapete rolante\\de saída]
    ]
]
    \end{forest}
\end{document}

相关内容