3

I'm creating a family tree using the genealogytree package. I intend to use the output for both print and an interactive web page.

For the web page, I can generate an SVG by using dvilualatex and dvisvgm, which I can display and add click handlers to the names in the tree to display more information in the page.

However, the generated text elements in the SVG are very sparse, containing only the inner text and all at the same level in the document, for example:

<text class='f2' transform='matrix(1 0 0 1 951.279 373.834)' x='-37.0118' y='-2.45512'>
    <tspan>N</tspan>
    <tspan x='-28.5655'>a</tspan>
    <tspan x='-23.9577'>m</tspan>
    <tspan x='-20.3533'>e</tspan>
</text>

I would like to include the database ID for each person in this node somehow.

I have been able to achieve this result by using a unique color for each person and post-processing the SVG to turn this back into the relevant IDs, but this is somewhat difficult to manage.

Is there a more natural way to achieve this?

A minimal example document:

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

\newcommand{\traditional}{
    \begin{minipage}[c][\gtrNodeMinHeight]{\gtrNodeMinWidth}
        \begin{center}
            \gtrBoxContent
        \end{center}
    \end{minipage}
}

\begin{document}
    \begin{tikzpicture}
        \genealogytree[node processor=\traditional]{
            child{
                g{Alice}
                p{Bob}
                c{Charlie}
            }
        }
    \end{tikzpicture}
\end{document}

Run through dvilualatex followed by dvisvgm to produce the SVG.

2

1 Answer 1

3

The suggestion to use dvisvgm specials allows a very elegant solution, simply wrapping each node in a "raw" <g> tag with whatever attributes are desired. Applying this to the example document above:

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

\newcommand{\traditional}{
    \begin{minipage}[c][\gtrNodeMinHeight]{\gtrNodeMinWidth}
        \begin{center}
            \gtrBoxContent
        \end{center}
    \end{minipage}
}

\begin{document}
    \begin{tikzpicture}
        \genealogytree[node processor=\traditional]{
            child{
                g{\special{dvisvgm:raw <g id='alice'>}Alice\special{dvisvgm:raw </g>}}
                p{\special{dvisvgm:raw <g id='bob'>}Bob\special{dvisvgm:raw </g>}}
                c{\special{dvisvgm:raw <g id='charlie'>}Charlie\special{dvisvgm:raw </g>}}
            }
        }
    \end{tikzpicture}
\end{document}

I'm sure this could be tidied up into a macro. In my case, I'm already generating the latex document via a templating language, so this sort of inline code is very practical.

1
  • Glad to hear the suggestion works, and your problem was solved so easily! Thanks for posting the solution as well. Dec 23, 2019 at 22:50

You must log in to answer this question.

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