2

I'm trying to make a simplified family tree like the one below using TikZ.

Family tree

I know about the genealogytree package and How can I improve this family tree in TikZ?, but those trees are too complicated, since they have names and use colours. I'm looking for something much simpler like the one above.

How can I do this?

2
  • 1
    What are you after exactly? Do you need only this one drawing or would you like to draw several different trees? Aug 2 at 7:39
  • Ideally, I’d like something that would be generalizable to arbitrary trees.
    – flame
    Aug 2 at 13:55

1 Answer 1

7

I don't know how you want to use this, but you can always define a few styles with TikZ which you can then use for creating different family trees.

This may get you started (maybe not the most elegant way to do this):

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, shapes}

\tikzset{
    family tree/.style={
        every node/.style={
            inner sep=0pt
        },
        person/.style={
            minimum size=15pt,
            circle
        },
        woman/.style={
            person,
            draw
        },
        man/.style={
            person,
            label={[% 
                person,
                draw, 
                regular polygon, 
                regular polygon sides=3, 
                minimum size=20pt, 
                yshift=-2pt,
                label position=center
            ]},
        },
        level 2/.style={
            sibling distance=1cm
        },
        to sibling/.style={
            level distance=1.5cm,
            edge from parent path={
                let \p1 = ({$(\tikzparentnode.center)!.5!(\tikzchildnode.center)$} -| \tikzparentnode.center),
                    \p2 = (\tikzchildnode\tikzchildanchor),
                    \n1 = { veclen(\x1,\x2) }
                in
                    (\tikzparentnode\tikzparentanchor) --
                    ({$(\tikzparentnode.center)!.5!(\tikzchildnode.center)$} -| \tikzparentnode.center)
                    [rounded corners={(\n1 < 10 ? 0pt : 10pt)}]
                    -| 
                    (\tikzchildnode\tikzchildanchor)
            },
            shorten <=2pt
        },
        sibling/.style={
            level distance=.75cm,
            edge from parent path={
                let \p1 = (\tikzparentnode.center),
                    \p2 = (\tikzchildnode\tikzchildanchor),
                    \n1 = { veclen(\x1,\x2) }
                in
                    [rounded corners={(\n1 < 10 ? 0pt : 10pt)}]
                    (\tikzparentnode.center)
                    -| 
                    (\tikzchildnode\tikzchildanchor)
            }
        },
        marriage/.style={
            double, 
            double distance=2pt,
            shorten >=2pt,
            shorten <=2pt
        }
    }
}

\begin{document}

\begin{tikzpicture}[family tree]

\node (t1) at (-3,0) {} 
    child[sibling] { node[man] {} 
        child[to sibling] { node[woman] {} }
        child[to sibling] { node[man] {} }
    }
    child[sibling] { node[woman] {} 
        child[to sibling] { node[man] (n3) {} }
    }
    child[sibling] { node[woman] (n1) {} };
    
\node (t2) at (3,0) {} 
    child[sibling] { node[man] (n2) {} }
    child[sibling] { node[man] {} 
        child[to sibling] { node[woman] {} }
    }
    child[sibling] { node[woman] {} 
        child[to sibling] { node[man] {} }
    };
    
\node (t3) at ($(n1)!.5!(n2)$) {} 
    child[to sibling] { node[man] {} }
    child[to sibling] { node[woman] {} };

\node[right of=n3, woman] (n4) {};

\draw[marriage] (n1) -- (n2);

\draw[marriage] (n3) -- (n4);

\end{tikzpicture}

\end{document}

enter image description here

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.