Open torfsen opened 3 years ago
The simplest solution is probably manually adjusting the layout by inserting a distance
, for example on F01 or H01: g[distance=3cm]{name={F01}}
:
Another option is to rearrange the tree by moving the C/E/B families to the beginning, but that may be undesirable if you prefer to have father/mother always left/right:
\documentclass{article}
\usepackage[a0paper]{geometry}
\usepackage{lmodern}
\usepackage[all]{genealogytree}
\begin{document}
\begin{genealogypicture}[
template=database pole,
insert phantom for childless families,
]
sandclock{
parent{
parent{
p{name={C01}}
p{name={C02}}
g{name={E01}}
}
parent{
p{name={B01}}
parent{
g{name={A01}}
c{name={A02}}
c{name={A03}}
c{name={A04}}
c{name={A05}}
c{name={A06}}
c{name={A07}}
c{name={A08}}
c{name={A09}}
c{name={A10}}
c{name={A11}}
}
g{name={D01}}
}
g{name={G01}}
c{name={G02}}
c{name={G03}}
c{name={G04}}
c{name={G05}}
c{name={G06}}
}
parent{
p{name={F01}}
p{name={F02}}
g{name={H01}}
c{name={H02}}
c{name={H03}}
c{name={H04}}
c{name={H05}}
c{name={H06}}
}
c{name={I01}}
}
\end{genealogypicture}
\end{document}
Thanks for your input, @mikkelee! I'll see whether I can use one of your suggested workarounds in my personal use case.
Nevertheless, I still think this is a bug in genealogytree
because IMO nothing prevents the G
and H
families to be moved to the right to avoid the overlap.
Technically, it is not a bug, because the autolayout algorithm produces the correct output, i.e. placing the nodes compact without overlapping. Family lines (edges) are not considered by the algorithm. Here, this gives an unwanted line overlapping.
The following code shows that the placement is correct:
\documentclass{article}
\usepackage[a0paper]{geometry}
\usepackage{lmodern}
\usepackage[all]{genealogytree}
\begin{document}
\begin{tikzpicture}
\genealogytree[
template=database pole,
show family,
%insert phantom for childless families,
]
{
sandclock{
parent{
parent{
parent{
g{name={A01}}
c{name={A02}}
c{name={A03}}
c{name={A04}}
c{name={A05}}
c{name={A06}}
c{name={A07}}
c{name={A08}}
c{name={A09}}
c{name={A10}}
c{name={A11}}
}
p{name={B01}}
g{name={D01}}
}
parent{
p{name={C01}}
p{name={C02}}
g{name={E01}}
}
g{name={G01}}
c{name={G02}}
c{name={G03}}
c{name={G04}}
c{name={G05}}
c{name={G06}}
}
parent{
p{name={F01}}
p{name={F02}}
g{name={H01}}
c{name={H02}}
c{name={H03}}
c{name={H04}}
c{name={H05}}
c{name={H06}}
}
c{name={I01}}
}
}
\gtrdebugdrawcontour{family number=2}{draw=blue,line width=2pt}
\gtrdebugdrawcontour{family number=6}{draw=red,line width=2pt}
\end{tikzpicture}
\end{document}
There is no automated way to prevent such kind of edge overlappings, because the autolayout does not consider edges at all.
insert phantom for childless families
does not help here. As @mikkelee wrote, you could adapt distances manually.
Another option would be to adapt the edges shift
or edges up
etc. (also manually). This keeps the nodes as they are, but avoid line overlapping:
\documentclass{article}
\usepackage[a0paper]{geometry}
\usepackage{lmodern}
\usepackage[all]{genealogytree}
\begin{document}
\begin{tikzpicture}
\genealogytree[
template=database pole,
%show family,
%parent distance in parent graph=10mm,
%insert phantom for childless families,
]
{
sandclock{
parent[edges up by=1 of 4]{% <-------------------------------------
parent{
parent{
g{name={A01}}
c{name={A02}}
c{name={A03}}
c{name={A04}}
c{name={A05}}
c{name={A06}}
c{name={A07}}
c{name={A08}}
c{name={A09}}
c{name={A10}}
c{name={A11}}
}
p{name={B01}}
g{name={D01}}
}
parent{
p{name={C01}}
p{name={C02}}
g{name={E01}}
}
g{name={G01}}
c{name={G02}}
c{name={G03}}
c{name={G04}}
c{name={G05}}
c{name={G06}}
}
parent[edges down by=1 of 4]{% <-------------------------------------
p{name={F01}}
p{name={F02}}
g{name={H01}}
c{name={H02}}
c{name={H03}}
c{name={H04}}
c{name={H05}}
c{name={H06}}
}
c{name={I01}}
}
}
%\gtrdebugdrawcontour{family number=2}{draw=blue,line width=2pt}
%\gtrdebugdrawcontour{family number=6}{draw=red,line width=2pt}
\end{tikzpicture}
\end{document}
Thanks for the clarification, @T-F-S. As a software developer I do understand that one may not consider this issue a bug in the layout algorithm (because, as you said, "the autolayout does not consider edges at all"). However, as a user I do not care about the details of the algorithm or its implementation -- I care about the results. And from this point of view I still do consider this issue a bug, because the result I get is not what I would have expected.
I appreciate your remarks regarding potential workarounds, but as I auto-generate the input for genealogytree
most of them will not be applicable to my personal use case.
If taking edges into account in the core algorithm is too difficult, then perhaps the edges up
/ edges down
could be auto-computed once the layout is complete? "Simply" alternating them between high and low in the same level should probably work.
The user view is clear to me. I am a user of genealogytree
myself and would also like to see an automated way for avoiding the overlapping. Unfortunately, alternating the high and low edge setting on a level is a non-trivial operation (not in principle, but for the current implementation).
I have a vague idea of an alteration for the autolayout algorithm to disallow slipping nodes of other families under the area defined by the parents (here E01 and D01). Currently, I have no time to investigate further in this direction. But, if I would do such a change in the future, possibly many existing layouts would change...
This issue should remain to be open as a reminder for the future.
As for machine-generated trees, you can assign id
s to the individual nodes. These can then be referred to and manipulated when the tree is displayed. This is especially practical if the tree is in a separate file, which means it can be regenerated while the extra options are untouched.
In my genealogytree-mkgraph script, I add the gedcom XREF
value to all individuals and families, so I can refer to them with eg. options for node
etc.
Here's an example where the graph is loaded from another file and is then manipulated in the .tex document:
\documentclass{article}
\usepackage[a0paper]{geometry}
\usepackage{lmodern}
\usepackage[all]{genealogytree}
% simulating an external file:
\usepackage{filecontents}
\begin{filecontents}{\jobname.database.graph}
sandclock{
parent{
parent{
parent{
g{name={A01}}
c{name={A02}}
c{name={A03}}
c{name={A04}}
c{name={A05}}
c{name={A06}}
c{name={A07}}
c{name={A08}}
c{name={A09}}
c{name={A10}}
c{name={A11}}
}
p{name={B01}}
g{name={D01}}
}
parent{
p{name={C01}}
p{name={C02}}
g{name={E01}}
}
g{name={G01}}
c{name={G02}}
c{name={G03}}
c{name={G04}}
c{name={G05}}
c{name={G06}}
}
parent{
p[id=F01]{name={F01}} % <- note the id
p{name={F02}}
g{name={H01}}
c{name={H02}}
c{name={H03}}
c{name={H04}}
c{name={H05}}
c{name={H06}}
}
c{name={I01}}
}
\end{filecontents}
% and loading the file:
\begin{document}
\begin{tikzpicture}
\genealogytreeinput[
template=database pole,
insert phantom for childless families,
options for node={F01}{distance=3cm}, % <- here we add the distance to the F01 node
]{\jobname.database.graph}
\end{tikzpicture}
\end{document}
@mikkelee: Thanks for the pointer to options for node
, that will certainly come in handy!
@T-F-S: Sounds good. Thanks for your work on this package!
The following is an extract from a larger tree of mine:
For me, this renders as follows:![image](https://user-images.githubusercontent.com/2877717/99880480-ddac7600-2c13-11eb-8c52-bea7545bb82f.png)
The lines for the![image](https://user-images.githubusercontent.com/2877717/99880500-02a0e900-2c14-11eb-8ddb-de48c5ad5b26.png)
G
andH
families overlap. If I comment outA02
(for example) then it renders as expected:I'm aware of #34, but my example doesn't have any childless families. I've added
insert phantom for childless families
nevertheless, but as expected it doesn't solve the issue.Here's the log file with all the version information: