# How to add 2nd husband of 2nd wife and descendants to genealogytree?

In my family, after my father (h1) and mother (w1) divorced, my father remarried to w2. So far so good. But in the genealogy tree I also would like to add the previous husband of w2 (w2-h2). How do I do that? I tried it with union, and you can see my attempt in the file below, but I commented it out since it gives me error when compiling.

\documentclass{article}

\usepackage[all]{genealogytree}

\begin{document}
% h=husband
% w=wife
% w2-h1=2nd wife's 1st husband
% c=child
\begin{genealogypicture}
child{
g[male]{h1}
p[female]{w1}
union{
p[female]{w2}
% union{
% p[male]{w2-h2}
% }
c{h1-w2's c}
}
c{w1-h1's  c}
}
\end{genealogypicture}

\end{document}


This is an attempt to answer the updated question. I learned a lot from this post.

\documentclass{article}
\usepackage[all]{genealogytree}

\begin{document}
\begin{tikzpicture}
% Tree for the common husband with descendents
% h=husband
% w=wife
% w2-h1=2nd wife's 1st husband
% c=child
\genealogytree{
child{
g[male]{h1}
p[female]{w1}
union{
p[female,id=wife2]{w2}
c{h1-w2's c}
}
c{w1-h1's  c}
}
}
\genealogytree[set position=wife at wife2]{
child{
g[female,id=wife]{w2}
p[male]{w2-h2}
}
}
\end{tikzpicture}

\end{document}


ANSWER TO MY INTERPRETATION OF THE FIRST VERSION OF THE QUESTION: This is more or less copied from p. 67 of the manual.

\documentclass{article}

\usepackage[all]{genealogytree}

\begin{document}
\begin{genealogypicture}
child{
p[female]{w1}
g[male]{h1}
c{w1-h1's c}
union{
p[female]{w2}
c{w2-h1's c}
}
}
\end{genealogypicture}
\end{document}


Of course, you can rearrange it as follows:

\documentclass{article}

\usepackage[all]{genealogytree}

\begin{document}
\begin{genealogypicture}
child{
g[male]{h1}
union{
p[female]{w1}
c{w1-h1's c}
}
p[female]{w2}
c{w2-h1's c}
}
\end{genealogypicture}
\end{document}


It even works in extreme situations.

\documentclass{article}
\usepackage{pdflscape}
\usepackage[all]{genealogytree}

\begin{document}
\begin{landscape}
\begin{genealogypicture}
child{
g[male]{Henry VIII}
union{
p[female]{Catherine of Aragon}
c{Mary I}
}
union{
p[female]{Anne Boleyn}
c{Elizabeth I}
}
union{
p[female]{Jane Seymour}
c{Edward VI}
}
union{
p[female]{Anne of Cleves}
}
union{
p[female]{Catherine Howard}
}
p[female]{Catherine Parr}
}
\end{genealogypicture}
\end{landscape}
\end{document}


• The question was about adding a previous (or just another) husband to w2. Adding several wives to the same husband was not a problem. My example already accomplished that with two wives. – Máté Wierdl Dec 1 '19 at 12:18
• I see the source of confusion in my original post, so I corrected the typo. The missing piece I cannot accomplish is w2-h2 not w2-h1, which I already have. – Máté Wierdl Dec 1 '19 at 12:27
• @MátéWierdl I tried to answer the edited post. – Schrödinger's cat Dec 1 '19 at 16:25