# Genogram or family tree with PGF/TikZ

Since it has been recommended to me in Stack Overflow to post it here, I will do so:

I want to draw a genogram with LaTeX.

I tried to do this with TikZ, but since you need to model at least 3 different relations between people (Children, Siblings, Couples), a standard tree model doesn't seem to fit.

Is there an easy way (maybe a template) to draw a genogram? If not, what would be the approach to build an own sub-package or something?

The main problem with latter being the dynamic positioning of elements (depending on the amount of branching) and the previously mentioned three relations.

I edited/extended the question, so it will be more clear of what I'm asking exactly:

Given is the following tree in TikZ/\usetikzlibrary{trees}:

which is created with:

\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\newcommand{\per}[1]{\parbox{2.5cm}{#1}}
\usetikzlibrary{trees}
\begin{document}

\tikzstyle{female} = [rectangle, draw, fill=red!20, rounded corners, minimum height=3em]
\tikzstyle{male} = [rectangle, draw, fill=blue!20, minimum height=3em]
\tikzstyle{neutral} = [rectangle, draw, fill=green!20, minimum height=3em]

\begin{tikzpicture}[level distance=4cm]
\node[neutral] {\per{Child}}
[edge from parent fork right,grow=right]
child {
node[female] {\per{Mother}}
child {
node[female] {\per{Mother's mother}}
}
child {
node[male] {\per{Mother's father}}
}
}
child {
node[male] {\per{Father}}
};
\end{tikzpicture}
\end{document}


Now I have two problems:

1. I want to add a Sibling to the Child and the Mother for example.
2. I want to add a Father's mother and Father's father resp.,

How would I do that?

-
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. –  Peter Grill Nov 13 '12 at 19:40
Thank you, I just changed it accordingly. –  Lumiukko Nov 14 '12 at 0:52
this appears to have been superseded by Genogram with LaTeX –  barbara beeton Nov 17 '12 at 19:14

## 3 Answers

I can provide a new answer based on a new package named genealogytree. On the time of writing, the version needed is 0.90 (2015/05/22). This package was specifically designed to typeset such kind of diagrams:

\documentclass{article}
\usepackage[all]{genealogytree}

\begin{document}

\begin{genealogypicture}[
timeflow=left,               % time flows from right to left
processing=tcolorbox,        % draw nodes with tcolorbox
node size from=8mm to 3cm,   % height of nodes
level size=2.8cm,            % width of nodes
level distance=1cm,          % generation distance
% redefine default setting for female,male,neuter:
tcbset={
female/.style={colback=red!20,arc=1mm},
male/.style={colback=blue!20,sharp corners},
neuter/.style={colback=green!20,arc=0.5mm},
},
%
box={colback=black,size=fbox,valign=center},    % node settings
%
edges={foreground={black,line width=0.25mm},    % edge settings
background={white,line width=0.5mm}}
]

%%%%%% the graph %%%%%%
parent{
g[neuter]{Child 1}
c[neuter]{Child 2}
parent{
g[male]{Father}
p[male]{Father's\\ father}
p[female]{Father's\\ mother}
}
parent{
g[female]{Mother}
c[female]{Aunt}
p[male]{Mother's\\ father}
p[female]{Mother's\\ mother}
}
}
\end{genealogypicture}

\end{document}


-

In this case I wouldn't use the trees library, but build the diagram using the positioning library; something along these lines:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzset{
every node/.style={rectangle,draw,minimum height=3em,text width=2.5cm},
female/.style = {fill=red!20, rounded corners},
male/.style = {fill=blue!20},
neutral/.style = {fill=green!20}
}

\begin{tikzpicture}[node distance=8pt and 33pt]

% the nodes
\node[neutral] (chi1) {Child 1};
\node[neutral,below= of chi1] (chi2) {Child 2};
\node[male,above right=of chi1] (father) {Father};
\node[female,below right=of chi2] (mother) {Mother};
\node[female,below =of mother] (aunt) {Aunt};
\node[male,above right=of father] (ffather) {Father's\\ father};
\node[female,below right=of father] (fmother) {Father's\\ mother};
\node[male,above right=of mother] (mfather) {Mother's\\ father};
\node[female,below right=of aunt] (mmother) {Mother's\\ mother};

% some auxiliary coordinates for the edges
\coordinate[right=15pt of chi1] (auxc1);
\coordinate[right=15pt of chi2] (auxc2);
\coordinate[right=15pt of father] (auxf);
\coordinate[right=15pt of mother] (auxm);
\coordinate[right=15pt of aunt] (auxa);

% the edges
\draw (father.west) -| (auxc1) |- (mother.west);
\draw (chi1) -- (auxc1);
\draw (chi2) -- (auxc2);
\draw (ffather.west) -| (auxf) |- (fmother.west);
\draw (father) -- (auxf);
\draw (mfather.west) -| (auxm) |- (mmother.west);
\draw (mother) -- (auxm);
\draw (aunt) -- (auxa);

\end{tikzpicture}

\end{document}


-

this appears to be similar to -- though most likely not the same as -- the medical pedigree trees described in papers delivered at tug meetings by leyla akhmadeeva and boris veytsman in 2008 and 2009, and subsequently published in tugboat:

the pedigree trees are not constructed with tikz, but with a package devised specifically for the purpose. nonetheless, you might get some ideas from that work.

-
Yes it is quite similar. In fact these are genograms. Unfortunately they are using a perl script to read a input file with the data of the later to be pedigree and generate the output used with the pst-pdgr in TeX. This alone wouldn't be a problem, however, I would like a TeX only solution, if possible, which will give me some freedom in design for nodes and coloring. The main problem seems to be, that a family tree is not a tree by definition, since every node can have more than one of each, successors and predecessors. –  Lumiukko Nov 13 '12 at 23:26