# Aligning nodes in tikz / genealogytree package

I am using the genealogytree package (which in turn uses TikZ) to draw up our family tree. It is very nifty and produces a nice output, but I have some problems with alignment.

What I want to do is to add my own family tree with ancestors growing towards the left, and then add my wife's family tree with ancestors growing towards the right. Finally, I want to add a third family tree with our children growing down.

Doing the individual trees is easy. Adding the second tree is also easy, I just specify that my wife should be aligned to myself with a 5 cm offset. The problem is introduced in the third tree, which would be us (again) and our children.

The way I imagined it was that I would set a second copy of myself overlapping my entry from the first tree, using "set position=DEL2 at DEL". Then I would set my wife's second copy overlapping her tree, using "set position=AKL2 at AKL". I first tried setting these options at the top level, right after \genealogytree is called, but it didn't work. So I tried setting the option for individual nodes, didn't work either.

The problem seems to be that the parent-distance overrides whatever offset I give the nodes. Since the parent distance is offset by 0.1 cm, but the two trees are separated by 5 cm, that means that the third tree will only align to one of us, while the other is locked to a 0.1 cm offset.

Easy solution: put the two first trees only 0.1 cm apart. Yes, technically this solves the problem, but it also puts our brothers and sisters very close together and it looks strange. I don't like it. Second easy solution: put parent distance as 2.5 cm (5 cm total). Yes, technically this solves the problem, but if the tree continues to grow with our children's children, then I want to keep their parental distance at 0.1 cm. I want to keep the two of us 5 cm apart in the third tree, but I want to keep parent distance for the rest of the tree at 0.1 cm.

Here's the code I've got right now (working due to parent distance being 2.5 cm, but not working if our children becomes parents):

\documentclass[9pt]{report}
\usepackage[a3paper,landscape,layoutoffset={0pt,0pt},hscale=0.85, vscale=0.9, inner=15mm, top=20mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage[swedish]{babel}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{xcolor}
\usepackage{epstopdf}
\usepackage[all]{genealogytree}
\tcbset{male/.style={colframe=black, colback=blue!06, watermark text=\gtrSymbolsSetDraw{blue!16}\gtrsymMale}}
\tcbset{female/.style={colframe=black, colback=red!07, watermark text=\gtrSymbolsSetDraw{red!17}\gtrsymFemale}}

\gtrset{
box={colback=white},
edges={swing,no background,foreground=black!50},
level size=5 cm,
node  size=3 cm,
level distance=1.75 cm,
child distance=1.25 cm,
parent distance=0.1 cm,
further distance = 3 cm
}

\begin{tikzpicture}
\genealogytree[timeflow=right, adjust position=DEL left of {0,0} distance 1cm]
{
sandclock
{
child
{
g[male]{Olle Lars Olof Evert Lindberg}
}
child
{
g[male]{Holger Nils Åke Lindberg}
}
child
{
g[female]{Hedvig Emma-Lena Liljenberg}
}
child
{
g[male, pivot, id=DEL]{Dan-Erik Sigurd Lindberg}
}
parent
{
c[female]{Kerstin Eriksson}
c[male]{Bengt Nilsson}
g[female, pivot]{Ingrid Birgitta Lindberg}
parent
{
g[male, pivot]{Axel Nilsson}
}
parent
{
g[female, pivot]{Anna Nilsson}
parent
{
g[male, pivot]{Lars Petter Hansander}
}
parent
{
g[female, pivot]{Emma Katarina Lindén}
}
}
}
parent
{
g[male, pivot]{Rolf Sigurd Lindberg}
c[female]{Margareta Eman}
c[female]{Monica Björklund}
parent
{
g[male, pivot]{Curt Sigurd Lindberg}
parent
{
g[male, pivot]{Sigurd Lindberg}
}
parent
{
g[female]{Elin Lindberg}
}
}
parent
{
g[female]{Hedvig Lindberg}
}
}
}
}

\genealogytree[timeflow=left, adjust position=AKL right of DEL distance 5 cm]
{
sandclock
{
child
{
g[male]{Attachai Keeratijarut}
}
child
{
g[female, pivot, id=AKL]{Angsana Keeratijarut Lindberg}
}
parent
{
g[male, pivot]{Anop Keeratijarut}
}
parent
{
g[female, pivot]{Renu Keeratijarut}
}
}
}

\genealogytree[timeflow=down,
%tree offset=0.4 cm,
level size=3 cm,
node  size=5 cm,
level distance=1.25 cm,
child distance=1.75 cm,
parent distance=2.5 cm,
further distance = 3 cm
]
{
sandclock
{
parent
{
g[male, pivot, id=DEL2, set position=DEL2 at DEL]{Dan-Erik Sigurd Lindberg}
}
parent
{
g[female, pivot, id=AKL2, set position=AKL2 at AKL]{Angsana Keeratijarut Lindberg}
}
c[male]{test}
}
}
\end{tikzpicture}

\end{document}


I am not sure, if I understood all requirements perfectly, but I would re-order the three partial trees to achieve a better result. In your MWE, the set position option was used twice for the same tree. But, the second call overwrites the first one.

My proposed solution re-orders the trees as follow:

• The first tree consists of you, your wife and your children (and their children etc). I kept the id values as DEL2 and AKL2.

• The second tree is your ancestor tree. Here, your second instance is used for alignment by set position=DEL at DEL2.

• The third tree is your wife's ancestor tree. Here, her second instance is used for alignment by set position=AKL at AKL2.

I kept all other values intact. With that construction, I hope that your requirements can be fulfilled. Of course, overlapping of the three trees could happen, if more children are added, but with adapted distances this could be repaired.

The code is:

\documentclass[9pt]{report}
\usepackage[a3paper,landscape,layoutoffset={0pt,0pt},hscale=0.85, vscale=0.9, inner=15mm, top=20mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage[swedish]{babel}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{xcolor}
\usepackage{epstopdf}
\usepackage[all]{genealogytree}

\begin{document}

\tcbset{male/.style={colframe=black, colback=blue!06, watermark text=\gtrSymbolsSetDraw{blue!16}\gtrsymMale}}
\tcbset{female/.style={colframe=black, colback=red!07, watermark text=\gtrSymbolsSetDraw{red!17}\gtrsymFemale}}

\gtrset{
box={colback=white},
edges={swing,no background,foreground=black!50},
}

\begin{tikzpicture}
\genealogytree[timeflow=down,
%tree offset=0.4 cm,
level size=3 cm,
node  size=5 cm,
level distance=1.25 cm,
child distance=1.75 cm,
parent distance=2.5 cm,
further distance = 3 cm
]
{
sandclock
{
parent
{
g[male, id=DEL2]{Dan-Erik Sigurd Lindberg}
}
parent
{
g[female, id=AKL2]{Angsana Keeratijarut Lindberg}
}
c[male]{test}
}
}

\genealogytree[timeflow=right, set position=DEL at DEL2,
box={colback=white},
edges={swing,no background,foreground=black!50},
level size=5 cm,
node  size=3 cm,
level distance=1.75 cm,
child distance=1.25 cm,
parent distance=0.1 cm,
further distance = 3 cm
]
{
sandclock
{
child
{
g[male]{Olle Lars Olof Evert Lindberg}
}
child
{
g[male]{Holger Nils Åke Lindberg}
}
child
{
g[female]{Hedvig Emma-Lena Liljenberg}
}
child
{
g[male, pivot, id=DEL]{Dan-Erik Sigurd Lindberg}
}
parent
{
c[female]{Kerstin Eriksson}
c[male]{Bengt Nilsson}
g[female, pivot]{Ingrid Birgitta Lindberg}
parent
{
g[male, pivot]{Axel Nilsson}
}
parent
{
g[female, pivot]{Anna Nilsson}
parent
{
g[male, pivot]{Lars Petter Hansander}
}
parent
{
g[female, pivot]{Emma Katarina Lindén}
}
}
}
parent
{
g[male, pivot]{Rolf Sigurd Lindberg}
c[female]{Margareta Eman}
c[female]{Monica Björklund}
parent
{
g[male, pivot]{Curt Sigurd Lindberg}
parent
{
g[male, pivot]{Sigurd Lindberg}
}
parent
{
g[female]{Elin Lindberg}
}
}
parent
{
g[female]{Hedvig Lindberg}
}
}
}
}

\genealogytree[timeflow=left, set position=AKL at AKL2,
box={colback=white},
edges={swing,no background,foreground=black!50},
level size=5 cm,
node  size=3 cm,
level distance=1.75 cm,
child distance=1.25 cm,
parent distance=0.1 cm,
further distance = 3 cm
]
{
sandclock
{
child
{
g[male]{Attachai Keeratijarut}
}
child
{
g[female, pivot, id=AKL]{Angsana Keeratijarut Lindberg}
}
parent
{
g[male, pivot]{Anop Keeratijarut}
}
parent
{
g[female, pivot]{Renu Keeratijarut}
}
}
}

\end{tikzpicture}

\end{document}

• So... You changed the order of the trees, but the tree you define first, DEL2 and AKL2 as parents, that still has parent distance 2.5 cm. So if I add children to that tree, then those children will also have parent distance 2.5 cm, right? This is what I wanted to avoid, keep the two trees separated, but only for DEL and AKL, all other nodes should be fairly close together. – GaRyu Nov 18 '15 at 16:50
• hey... I bet I could use your solution, set parent distance to 0.1 cm, and then use the distance option for the DEL2 and AKL2 nodes to offset them? Can I? I will try this when I get a chance. – GaRyu Nov 18 '15 at 16:53
• g[male, distance=2.5 cm, id=DEL1]{Dan-Erik Lindberg} in the first tree allows for parent distance=0.1 cm in all other trees displaying correctly (most of the time). Marking this as solved. Thanks! – GaRyu Nov 18 '15 at 18:41
• @GaRyu Like I said, I was not sure if I understood all requirements correct, but this new structure has some more degrees of freedom. I'm glad to hear that this was helpful. – Thomas F. Sturm Nov 19 '15 at 6:36

Dirty solution:

Keep adding new family trees, and aligning them to our kids, at the point when they start their families. I guess this would work, I didn't try it, but it is not very pretty in the code.

Basically, this solution requires:

1. My own family tree
2. My wife's family tree
3. A family tree to tie us together with 5 cm parent distance and all our kids
4. One additional tree per kid, which can then continue to grow.

I did think of this myself, and in a way it does answer the question, so maybe it's foolish of me to post the question, but I really would like a more neat solution, rather than adding tree upon tree like this.

• Um, you asked a question and then immediately posted an "answer" yourself. Probably remove your answer and add it to the question. – Aubrey Blumsohn Nov 17 '15 at 20:47
• Like I said, it kind of solves the problem, but it is a dirty and unwanted solution. I would much prefer a better solution, but if there is no better solution then I want to be able to mark the question as solved anyway at some point. It is fairly common practice to do this, and StackExchange even offers a special reward for "answering your own question", or at least it used to. – GaRyu Nov 18 '15 at 12:03