[Tex/LaTex] Aligning nodes in tikz / genealogytree package

genealogytreetikz-pgf

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}

Best Answer

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.

enter image description here

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}
Related Question