TransWikia.com

Sharing portions of graph in genealogytree

TeX - LaTeX Asked by Chris Yungmann on February 13, 2021

How can I reuse a portion of a graph between two different genealogytree instances? Here is a simplified example of code that just uses manual duplication, but I would like to extract out the graph in the second one to a command or similar to use as part of the first tree.

documentclass{letter}
usepackage[all]{genealogytree}
begin{document}
  begin{autosizetikzpicture}{linewidth}{}
    genealogytree[]{
      parent{
        g{Child A}
        parent{
          g{Parent A}
          p{Grandparent A}
          p{Grandparent B}
        }
        parent{
          g{Parent B}
          p{Grandparent C}
          p{Grandparent D}
        }
      }
    }
  end{autosizetikzpicture}
  begin{autosizetikzpicture}{linewidth}{}
    genealogytree[]{
      parent{
        g{Parent A}
        p{Grandparent A}
        p{Grandparent B}
      }
    }
  end{autosizetikzpicture}
end{document}

I tried defining the second tree inside a newcommand* but then get Package genealogytree Error: Parser: unfeasible token. when I try to use it.

One Answer

I think I found a solution using the insert control sequence documented in §4.10 Control Sequence 'insert' (p. 75) of the manual:

documentclass{letter}
usepackage[all]{genealogytree}
begin{document}
  newcommand*{secondTree}{%
    parent{
      g{Parent A}
      p{Grandparent A}
      p{Grandparent B}
    }
  }
  begin{autosizetikzpicture}{linewidth}{}
    genealogytree[]{
      parent{
        g{Child A}
        insert{secondTree}
        parent{
          g{Parent B}
          p{Grandparent C}
          p{Grandparent D}
        }
      }
    }
  end{autosizetikzpicture}
  begin{autosizetikzpicture}{linewidth}{}
    genealogytree[]{
      insert{secondTree}
    }
  end{autosizetikzpicture}
end{document}

Answered by Chris Yungmann on February 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP