T-F-S / genealogytree

pedigree and genealogy tree diagrams
LaTeX Project Public License v1.3c
47 stars 7 forks source link

Advanced siblings distance #21

Closed jojomi closed 5 years ago

jojomi commented 5 years ago

As far as I understand the auto-layout algorithm it tries to minimize space used by letting families overlap logically.

Most of the time that is a good thing because otherwise printing would be nearly impossible for real diagrams, but sometimes it kind of "hides" people in a tree.

Given this code:

Click to expand \documentclass{scrartcl} \usepackage[ngerman]{babel} \usepackage{microtype,ellipsis} \usepackage[all]{genealogytree} \pagestyle{empty} \begin{document} \begin{tikzpicture} \genealogytree[ processing=database, template=database sideways, database format=full marriage below, timeflow=right, list separators hang, proband level=1, ]% { child { g{ name = {root}, } child { g { name = {child 1}, } c{ name = {grandchild 1}, } c{ name = {grandchild 2}, } c{ name = {grandchild 3}, } c{ name = {grandchild 4}, } c{ name = {grandchild 5}, } c{ name = {grandchild 6}, } } c{ name = {child 2}, } c{ name = {child 3}, } } } \end{tikzpicture} \end{document}

I would like to make sure that child2 is not shadowed left of the grandchildren that only belong to child1. I know about further distance and the child distance in child tree, but I don't see a way to accomplish my goal automatically. The only thing I have found working is assigning IDs and doing this: options for node={c2,c3}{tikz={yshift=-2cm}},.

Any hints what I could do here?

output desired-output

T-F-S commented 5 years ago

You could insert a phantom grandchild for child2, e.g. by

child{
  g{name = {child 2}}
  c[phantom]{}
}

Then, space is reserved and you get a picture like your second screenshot without fiddling the distance manually. The full code is:

\documentclass{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{microtype,ellipsis}
\usepackage[all]{genealogytree}

\pagestyle{empty}

\begin{document}
\begin{tikzpicture}
\genealogytree[
processing=database,
template=database sideways,
database format=full marriage below,
timeflow=right,
list separators hang,
proband level=1,
]%
{
child {
g{
name = {root},
}
child {
g {
name = {child 1},
}
c{
name = {grandchild 1},
}
c{
name = {grandchild 2},
}
c{
name = {grandchild 3},
}
c{
name = {grandchild 4},
}
c{
name = {grandchild 5},
}
c{
name = {grandchild 6},
}
}
child{
  g{name = {child 2}}
  c[phantom]{}
}
c{
name = {child 3},
}
}
}
\end{tikzpicture}
\end{document}

If child2 is a g node with ID inside a child, the phantom could also be inserted by something like insert after node.

jojomi commented 5 years ago

Thanks for the idea!

jojomi commented 5 years ago

It worked nicely using insert after node={SchmKlau1947}{c[phantom]{}}, in a case where I already had two parents and hence a family with a g node. Is there also a way to do it inside the genealogytree options in the case of a single c node that needs a phantom child?

T-F-S commented 5 years ago

No, I fear that is not possible.

Maybe, the c node could be set to ignore and afterwards be replaced by a child with a phantom child, but that sounds quite complicate and may lead to technical problems...