1

I work with genealogy tree and want to create custom edges between two nodes. As an example, I want to redo the family relationship I presented here. The following MWE contains a modified version of the mentioned example tree. This time, however, I want to draw the line not within the genealogy tree package but by adding a custom edge between the two nodes as a tikz command.

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

\gtrset{Pattern/.style={ 
        template=signpost, 
        box={colback=black!20!white, no shadow, fontupper=\tiny,
        size=small,halign=center,valign=center},
        processing = fit, 
        edges={swing, no background, foreground=black},
        level distance=40mm, level 1/.style={further distance=1mm}, 
        level 2/.style={further distance=1mm} 
    }
}

    \begin{document} 
        \begin{tikzpicture} 
        \genealogytree[Pattern]{ 

        child{
            g[male]{A}
        p[female]{B} 
        child{
         g[female]{C}
         p[male]{D}   
         c[male]{E}    
    }
    child{
    g[female]{F}
    c[male]{G}
    }
    }
    }
    \end{tikzpicture} 
    \end{document}

The document looks like this.

enter image description here

To illustrate what the tree should look like in the end:

enter image description here

pst's solution within the genealogytree package works well. Nevertheless, I would want to implement it just with pure tikz. Is there a way to do it?

1 Answer 1

3

If you use the id option, you can use the name to refer to nodes and do what you will with them after the tree is completed.

For example, using id=D and id=G, we can add the line

\draw [magenta, line width=1pt] (D) [out=-60,in=135] to (G);

to produce

result

Note that edges drawn this way will be drawn over the existing tree, so you will need to make sure to avoid any nodes or use layers to add the edges behind the tree. This contrasts with the solution you don't want, where the edges are all drawn before the nodes, so you don't have to worry about putting them behind.

Complete code:

\documentclass[border=9pt]{standalone} 
\usepackage[all]{genealogytree}              

\gtrset{Pattern/.style={ 
    template=signpost, 
    box={colback=black!20!white, no shadow, fontupper=\tiny,
      size=small,halign=center,valign=center},
    processing = fit, 
    edges={swing, no background, foreground=black},
    level distance=40mm, level 1/.style={further distance=1mm}, 
    level 2/.style={further distance=1mm} 
  }
}

\begin{document} 
\begin{tikzpicture} 
  \genealogytree[Pattern]{ 

    child{
      g[male]{A}
      p[female]{B} 
      child{
        g[female]{C}
        p[male,id=D]{D}   
        c[male]{E}    
      }
      child{
        g[female]{F}
        c[male,id=G]{G}
      }
    }
  }
  \draw [magenta, line width=1pt] (D) [out=-60,in=135] to (G);
\end{tikzpicture} 
\end{document}
2
  • With this solution, I get a "Package pgf Error: No shape named is known"-error. Why doesn't that occur with your solution?
    – Taufi
    Dec 13, 2019 at 14:52
  • @Taufi Do you mean you get that with exactly my code or you get it when you try to incorporate it into your larger document?
    – cfr
    Dec 13, 2019 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .