25

I looking for a simple way to typeset a genealogical tree in LaTeX.

In particular, I'm interested in typesetting a so-called "Ahnentafel", that is a tree that shows me, my parents, my grandparents, my great-grandparents etc. In other words, it is a hierarchical tree in which the number of branches doubles at each level.

Is there a package that can help me? Sadly, http://www.ctan.org/topic/genealogy is empty.

I've noted a few posts recommending TikZ for drawing trees. I've never used TikZ, and I'm reluctant to dive into it just for this purpose. But if I must, I must.

EDIT:

Here's an example of what I want to create:

This is a 3-generation Ahnentafel.

This is a 3-generation Ahnentafel

  • could you provide a sample image in your question? – cmhughes May 11 '14 at 16:03
  • See e.g. tex.stackexchange.com/questions/23241/… – Alan Munn May 11 '14 at 16:13
  • @cmhughes, I've done so. – oz1cz May 11 '14 at 17:16
  • Not completely TeX related, but you can use gramps-project.org . Which generated Graphviz, dot, and PDF tree. You can include the PDF graphics directly or use dot2tex or dot2texi to include it you documents. – alfC Nov 14 '15 at 21:15
24

Here's another option using forest to illustrate some other of its features:

\documentclass{standalone}
\usepackage{tabularx}
\usepackage{forest}
\usetikzlibrary{shapes.geometric}

% comment out the following four lines if the Helvet Neue font are not available:
\usepackage{fontspec}
\newfontfamily\namefont[]{Helvetica Neue Condensed Bold}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Helvetica Neue Light}

\definecolor{color1}{HTML}{FFCB73}
\definecolor{color2}{HTML}{FFA100}

\newcommand\Person[5]{%
  {\namefont #1} \\
  \begin{tabularx}{4.5cm}[t]{@{}r@{\hspace*{2pt}}X@{}}
  b: & #2 \\
  & #3 \\
  d: & #4 \\
  & #5
  \end{tabularx}%
}

\begin{document}

\begin{forest}
delay={
  for tree={
    edge path={
      \noexpand\path[\forestoption{edge}]
        ([xshift=-(6pt-1pt*level)].child anchor) to[out=180,in=0]
        ([xshift=(6pt-1pt*level)]!u.parent anchor)\forestoption{edge label};
    },
    if n=1
      {fill=color1,shape=tape,tape bend bottom=none}
      {if n'=1
        {fill=color2,shape=tape,tape bend top=none}
        {}
      }
  }
},
for tree={
  line width=3pt,
  inner sep=8pt,
  draw=brown,
  minimum size=1cm,
  text width=4.5cm,
  child anchor=west,
  parent anchor=east,
  grow=east,
  l sep=2cm,
  s sep=10pt,
  draw,
  anchor=west,
  edge={line width=(18pt-3pt*level),line cap=rect,color=brown},
}
[\Person{Abraham /LINCOLN/}{12 Feb 1809}{Hardin (Larue), KY}{15 Apr 1865}{Washington, DC},fill=color2
  [\Person{Nancy /HANKS/}{5 Feb 1784}{Campbell Co., Virginia}{5 Oct 1818}{Centryville, Spencer, Ind}
   [\Person{Nancy /SHIPLEY/}{ABT 1745}{Pembroke, Wash, ME}{}{Amelia, Amelia, VA}
     [\Person{Sarah Or Rachel}{ABT 1723}{}{}{}
     ]
     [\Person{Robert /SHIPLEY/}{ABT 1719}{}{}{}
     ]
   ]
   [\Person{Joseph /HANKS/}{ABT 1740}{Pembroke, Wash, ME}{}{Amelia, Amelia, VA}
     [\Person{Sarah /EVANS/}{ABT 1714}{Pembroke, Wash, ME}{}{}
     ]
     [\Person{John /HANKS/}{22 Oct 1709}{Pembroke, Wash, ME}{6 Sep 1742}{Pembroke, Wash, ME}
     ]
   ]
  ]
  [\Person{Thomas /LINCOLN/}{20 Jan 1780}{Rockingham, VA}{17 Jan 1851}{Beechland, Co., KY.}
    [\Person{Bethsheba /HERRING/}{1746}{Rockingham, Co., VA.}{}{}
      []
      []
    ]
    [\Person{Abraham /LINCOLN/}{17 May 1744}{Berks, Co., Penn.}{1786}{Jefferson County, KY}
      [\Person{Rebecca /FLOWERS/}{30 Mar 1720}{Berks, Co., Penn.}{1806}{Berks, Co., Penn}
      ]
      [\Person{John /LINCOLN/}{3 May 1711}{Freehold, Monmouth, N.J.}{1778}{PA}
      ]
    ]
  ]
]
\end{forest}

\end{document}

The result:

enter image description here

In this solution, the edges are curved so as to suggest a tree and the thickness of the branches automatically diminishes as the level increases; also, male and female persons are distinguished by selecting different attributes for their nodes (shape, filling); all this is done at the tree specification.

The Helvet Neue font used in my example can be downloaded from rebba pocket.

  • Very, very beautiful, Gonzalo! I'm impressed. – oz1cz May 12 '14 at 5:53
  • 2
    (+1) But it hardly looks much like the target image specified in the question's desiderata! – cfr Jun 9 '14 at 2:00
  • The link for the Helvet Neue font is broken. – sophros Nov 18 '18 at 14:49
  • forest package looks good as long as you want to draw no-sibling tree. I could not make it working so to visualize all siblings and maintain the link to parents. – sophros Nov 19 '18 at 7:25
21

The newly released genealogytree package would help you! This post previously mentioned version 0.10 alpha I had to install the current version manually, because the current Latex distribution is frozen until the new upgrade.

A current example of what can be done with the package: http://mirrors.ctan.org/macros/latex/contrib/genealogytree/genealogytree-example-2.pdf example2

I can not add the MWE from this picture, because I am not able to parse it myself.

You can find the package here: http://www.ctan.org/pkg/genealogytree

From The genealogytree package Manual for version 0.90 (2015/05/22):

Pedigree and genealogy tree diagrams are proven tools to visualize genetic and relational connections between individuals. The naming for mathematical tree structures with parent nodes and child nodes is traded from historical family diagrams. However, even the smallest family entity consisting of two parents and several children is no mathematical tree but a more general graph. The genealogytree package provides a set of tools to typeset such genealogy trees or, more precisely, to typeset a set of special graphs for the description of family-like structures. The package uses an auto-layout algorithm which can be customized to e.g. prioritize certain paths.

  • 1
    Very interesting. It's still only an alpha version, but I'll follow its evolution. – oz1cz Jan 23 '15 at 9:38
  • Much better than using forest, in my opinion! – Alessandro Cuttin May 26 '15 at 9:36
  • For family trees specifically, this does, indeed, look very nice. But i think @AlessandroCuttin is a little unfair since forest really is not designed to draw graphs - as opposed to trees - at all, so it will always be a bit of a hack to draw tree-like structures without a single root. – cfr Jun 28 '15 at 16:11
15

You could use forest which I've recently been learning to use for tree diagrams. This code owes pretty much everything to Gonzalo Medina's answer to my question about using forest in this way:

\documentclass[tikz,12pt]{standalone}
\usetikzlibrary{calc,positioning,backgrounds,arrows.meta}
\usepackage{forest}
\pagestyle{empty}

\begin{document}

\begin{forest}
  for tree={
    child anchor=west,
    parent anchor=east,
    grow=east,
    draw,
    anchor=west,
    edge path={
      \noexpand\path[\forestoption{edge}]
        (.child anchor) -| +(-5pt,0) -- +(-5pt,0) |-
        (!u.parent anchor)\forestoption{edge label};
    },
  }
  [Me
    [My Father
      [My Father's Father
      ]
      [My Father's Mother
      ]
    ]
    [My Mother
      [My Mother's Father
      ]
      [My Mother's Mother
      ]
    ]
  ]
\end{forest}

\end{document}

Family Forest

5

I have an "indirect" solution to your problem. There are two free programs that leap into mind that could solve your problem: A) Gramps www.gramps-project.org - a fully blown genealogy program (open source) that can draw various types of an "Ahnentafel" and can also export written reports to Latex. There are program versions for Linux, Mac and Win32. If you are on Linux I would recommend version 3.4.7 B) yEd - a Java-based Editor (closed source but free) that can read and visualize/print also Gedcom files. So if you just have a Gedcom file, try yEd. It has also a Weblaunch facility to try it out.

4

enter image description here

Another indirect solution. Some years ago I used a program called LifeLines http://lifelines.sourceforge.net which reads a GEDCOM (try googling) file and can produce a variety of reports and trees in LaTeX format (and others as well).

EDIT Above I have added a scan of a couple of pages of LaTeX output.

  • Is there any screenshot or sample of the latex output? I'd be interested in playing with this. Thanks for your efforts, it seems like no one else has undertaken this kind of integration with tex. – Sridhar Sarnobat Oct 31 '15 at 18:18
  • 1
    If you send me (herries.press@earthlink.net) your email address I can send you some example files. – Peter Wilson Nov 1 '15 at 21:14
  • GRUMP: I first programmed using machine code. Now I don't know how to upload LaTeX source files to the site,how todownload them so that i can try them out, or to upload the results. Further, the 5 minute limit on creating a comment is too short, – Peter Wilson Nov 1 '15 at 21:24
  • 1
    Added an image. – Peter Wilson Nov 2 '15 at 15:15
1

I played with this a bit:

    \documentclass[a4paper,10pt]{book}
\usepackage[ngerman]{babel} % Deutsche Sprachanpassungen
\usepackage[utf8]{inputenc}  % Direkte Angabe von Umlauten im Dokument.
\usepackage[left=1.0cm,right=1cm,top=1cm,bottom=1cm,includeheadfoot]{geometry} 
\usepackage{tikz}
\usepackage{color}
\usetikzlibrary{positioning}
\begin{document}

\tikzset{
female/.style={font=\fontsize{9}{10}\color{black!100}\ttfamily, fill=red!20, rounded corners=10pt, rectangle,draw,minimum height=4.8em,text width=4.5cm},
male/.style={font=\fontsize{9}{10}\color{black!100}\ttfamily, fill=blue!20, rectangle,draw,minimum height=4.8em,text width=4.5cm, },
neutral/.style={draw=black!0,text width=3.2cm, minimum height=1em}, 
siblingm/.style={font=\fontsize{9}{10}\color{black!100}\ttfamily, fill=blue!20,  rectangle,draw, text width=3.5cm, minimum height=1em},
siblingf/.style={font=\fontsize{9}{10}\color{black!100}\ttfamily, fill=red!20, rounded corners=10pt, rectangle,draw, text width=3.5cm, minimum height=1em}}
\begin{tikzpicture}[node distance=5pt and 20pt] %distance ist  zwischenraum untereinander
\node(zerou) [neutral,right=35em] {Ur-Grosseltern}; %Kopfzeile Bezeichnung rechts
\node(zerog) [neutral,left=of zerou] {Grosseltern}; %Kopfzeile zweites von rechts
\node(zeroe) [neutral,left=of zerog] {Eltern}; %Kopfzeile drittes von rechts
\node(zerok) [neutral,left=of zeroe] {Kinder}; %Kopfzeile links

% hier kommen die UrGrosseltern, dazwischen jeweils das Kind
\node[male,below=of zerou] (8) {8 HS\\ \textit{geboren}  \\ verh \\ Leop};
\node[male,below left=of 8] (4) {4\\1\\2\\3};
\node[female,below right=of 4] (9) {9\\1\\2\\3};

\node[neutral,below =of 9] (invisible1) {\textcolor{white}{1}}; %unsichtbar, abstand halten und punkt fuer spaeter benutzen

\node [male,below= of invisible1] (10) {10\\1\\2\\3};
\node[female,below left=of 10] (5) {5\\1\\2\\3};
\node[female,below right=of 5] (11) {11\\1\\2\\3};

\node[neutral,below =of 11] (invisible2) {\textcolor{white}{1}}; %unsichtbar, abstand halten und punkt fuer spaeter benutzen

\node [male,below= of invisible2] (12) {12\\1\\2\\3};
\node[male,below left=of 12] (6) {6\\1\\2\\3};
\node[female,below right=of 6] (13) {13\\1\\2\\3};

\node[neutral,below =of 13] (invisible3){\textcolor{white}{1}}; %unsichtbar, abstand halten und punkt fuer spaeter benutzen

\node [male,below= of invisible3] (14) {14\\1\\2\\3};
\node[female,below left=of 14] (7) {7\\1\\2\\3};
\node[female,below right=of 7] (15) {15\\1\\2\\3};

%hier kommen die Eltern
\node [male,left=4cm of invisible1] (2) {2\\1\\2\\3};  % richtet sich an aus
\node [female,left=4cm of invisible3] (3) {3\\1\\2\\3}; % richtet sich an aus

%hier kommen die Kinder. Achtung, Reihenfolge beachten
\node [siblingf,  left=9.5cm of invisible2] (1) {2 Kind\\1}; %liegt im Zentrum
\node [siblingm, above= of 1] (c) {1 Kind\\1}; % eins darueber
\node [siblingm, below= of 1] (a) {3 Kind\\1}; % eins darunter
\node [siblingm, below= of a] (b) {4 Kind\\1};
\node [siblingf, below= of b] (d) {5 Kind\\1};

\coordinate[right=12pt of 3] (aux3);
\coordinate[right=12pt of 4] (aux4); 
\coordinate[right=12pt of 5] (aux5);
\coordinate[right=12pt of 6] (aux6);
\coordinate[right=12pt of 7] (aux7);

\coordinate[right=12pt of 1] (aux1); 
\coordinate[right=12pt of a] (auxa);
\coordinate[right=12pt of b] (auxb);
\coordinate[right=12pt of c] (auxc);

\coordinate[right=12pt of d] (auxd);


% die Eheverbindungen
\draw (8.west) -| (aux4) |- (9.west);   %Eheverbindung
\draw (4) -- (aux4);                    %rechtsstrich am Kasten und ihre Bezeichnung
\draw (10.west) -| (aux5) |- (11.west); %Eheverbindung
\draw (5) -- (aux5);                    %rechtsstrich am Kasten und ihre Bezeichnung
\draw (12.west) -| (aux6) |- (13.west); %Eheverbindung
\draw (6) -- (aux6);                    %rechtsstrich am Kasten und ihre Bezeichnung
\draw (14.west) -| (aux7) |- (15.west); %Eheverbindung
\draw (7) -- (aux7);                    %rechtsstrich am Kasten und ihre Bezeichnung

\draw (4.west) -| (2) |- (5.west);      %Eheverbindung
\draw (6.west) -| (3) |- (7.west);      %Eheverbindung

\draw (2.west) -| (aux1) |- (3.west);   %Eheverbindung

\draw (1) -- (aux1); %Kind 2 zentriert, ausgangspunkt, rechtsstrich am Kasten und ihre Bezeichnung
\draw (a) -- (auxa);    %Kind 3 rechtsstrich am Kasten und ihre Bezeichnung
\draw (b) -- (auxb);    %Kind 4 rechtsstrich am Kasten und ihre Bezeichnung
\draw (c) -- (auxc);    %Kind 1  rechtsstrich am Kasten und ihre Bezeichnung
\draw (d) -- (auxd);    %Kind 5 rechtsstrich am Kasten und ihre Bezeichnung
\end{tikzpicture}
\end{document}

The result is this: enter image description here

0

After years avoiding tikz because I thought it was complicated (having used latex for 20 years), I moved to it, because my 2nd month intern, who never used latex before, got into it so fast. So it might be worth some of your time. Pointers:

  • Talking about recursion ... – MaxNoe Nov 16 '15 at 8:33
0

I write software that generates family trees. Charting Companion can output PDF, SVG, DXF and RTF. I could adapt to TeX, but there is so little demand for it and such a small target market, it would difficult to justify the expense.

Note that Charting Companion reads data directly from genealogy software databases (Family Tree Maker, Legacy, RootsMagic, Ancestral Quest, Family Historian, GRAMPS, GEDCOM), as well as Web-based services (FamilySearch.org, Geni.com, MyHeritage.com).

Some background

I used TeX in the early 80's. I took a TeX class at Stanford from Donald Knuth himself, and had lunch with the Doctor, who has a delightful sense of humour. I have an autographed first edition of "TeX and Metafont". I wrote a driver to convert DVI files into native Xerox 9700 page formatting codes (120 impressions/min. 2-sided in 1979). I managed a service bureau that did text composition with TeX on an Apollo Domain workstation.

Hard-coding your family tree in a TeX document is not practical. You will find that you are constantly adding people, events, dates and places. It is better to use a general-purpose genealogy program (as mentioned above), enter the data once and only once, and read the database to produce a whole range of charts: Ancestor, Descendant, Fan, Trellis, Fractal, Dandelion, Books, etc.

As I said, I'm interested in outputting TeX, but my observation is that genealogists don't use TeX, and TeX users don't use genealogy programs. It's a Venn diagram with empty intersection.

Do this in hand-crafted TeX:

enter image description here

  • Although not specifically a family tree in binary tree format (which I assume is why this answer has received so many down-votes), this certainly does belong in a family tree question. Interesting format that I appreciate having seen. +1 – Robert Wolfe Oct 30 '18 at 13:01

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.