1

I have the following TikZ forest:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,fit}
\usepackage{forest}
\tikzset{
    >=stealth,
    auto,
    thick,
    node distance=2.5cm,
    transform shape,
}

\begin{document}
\begin{forest}
for tree={
    child anchor=west,
    parent anchor=east,
    grow=east,
    draw,
    thick,
    rounded corners=1mm,
    anchor=west,
    edge path={
    \noexpand\path[\forestoption{edge}]
        (.child anchor) -| +(-5pt,0) -- +(-5pt,0) |-
        (!u.parent anchor)\forestoption{edge label};
    },
}
[Bill
    [Bob
        [Rich
            [Sam]
            [Susan]
        ]
        [Patty]
    ]
    [Mary
        [Mike]
        [Kathy]
    ]
]
\end{forest}
\end{document}

Which generates the image:

enter image description here

The tree 'flows' from west to east. I've been playing with the anchor settings to see if I can get it to grow from north to south with the lowest node being the one labeled by Bill (like a standard family tree), but I can't seem to make the edges look right and not overlap.

Any suggestions?

2

Too long for a comment. The "flow" of your tree is controlled by the key grow=east, but you seem to want grow=south. Then you need to adjust the anchors of parents and children, as you anticipate. Note that your \tikzset{...} stuff has no effect, so I dropped it.

\documentclass[tikz]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={parent anchor=south,child anchor=north,
    draw,
    thick,
    rounded corners=1mm,
    edge path={
    \noexpand\path[\forestoption{edge}]
        (!u.parent anchor) --  +(0,-5pt) -|
        (.child anchor)\forestoption{edge label};
    },
}
[Bill
    [Bob
        [Rich
            [Sam]
            [Susan]
        ]
        [Patty]
    ]
    [Mary
        [Mike]
        [Kathy]
    ]
]
\end{forest}
\end{document}

enter image description here

An arguably easier way to obtain (almost) the same result is to just use forked edges, which are available if you load the edges library, i.e. \usepackage[edges]{forest}.

\documentclass[tikz]{standalone}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
for tree={grow=south,
    draw,
    thick,
    rounded corners=1mm,
}
[Bill
    [Bob
        [Rich
            [Sam]
            [Susan]
        ]
        [Patty]
    ]
    [Mary
        [Mike]
        [Kathy]
    ]
]
\end{forest}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.