1

I have a lot of information to write in a genealogy tree. I would like to write part of it in the tree and the rest on the next page, accessible when clicking on the person name.

The tree is created with the package genealogytree and the data is stored in a separate file test_database.tex.

I tried to create a \newcommand to print data from the database but nothing is printed. Can someone explain to me how to pass the arguments properly into new command?

The final objective is to print the data for all the people, ideally without typing each name in the newly defined command to print its data.

MWE

test.tex

\documentclass{article}

\usepackage[all]{genealogytree}

\begin{document}
    
    % Define new keys in genealogytree database
    \pgfkeys{/gtr/database/.cd,
        nationality/.store in=\nationality,
        nationality=unknown,
        given name/.store in=\givenname,
        family name/.store in=\familyname,
        language/.store in=\language
    }
    
    % Define new format for genealogytree
    \gtrDeclareDatabaseFormat{xTestFormat}
    {
        % Define box title based on nationality
        \ifdefined\nationality
        \gtrset{box={title=\nationality}}
        \fi
        % Define tcolorbox parameters based on 'nationality' key
        \tcbset{unknown/.style={colback=black!5!white,colframe=black}}
        \tcbset{french/.style={colback=blue!5!white,colframe=blue}}
        \tcbset{british/.style={colback=red!5!white,colframe=red}}  
    }
    { % Define informations to print in the box
        \gtrPrintSex~\textcolor{blue}{\textbf{\givenname}}
        
        \ifdefined\familyname
        \familyname
        \fi
        
        \language
        
        \gtrifcommentdefined{\gtrPrintComment}{}
    }
    
    \input{test_database}
    
    % Create a command to print people complete data
    \newcommand\PrintCompletePeople[1]{
            
        This is the direct output: #1
        
        I want to know what is behind the key:
        
        \pgfkeys{/mydata/.cd,
            nationalitybis/.store in=\nationalitybis,
            nationalitybis=\pgfkeysvalueof{/gtr/database/people/#1/nationality}
        }
    
        \nationalitybis
        
        but nothing is printed
    }
    
    
    \begin{tikzpicture}
        
        \genealogytree[
            timeflow=down,
            processing=database,
            database format=xTestFormat,
            box={\nationality}
        ]
        {child[id=fam_Water]{
            p[id=Justine]{people=JustineID}
            g[id=Tom]{people=TomID}
            c[id=Jane]{people=JaneID}
            }
        }
        
    \end{tikzpicture}

    \newpage
    
    \PrintCompletePeople{JaneID}
    
    
    
\end{document}

test_database.tex

% Create database

% Jane Water
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/JaneID/.style={
        female,
        nationality = british,
        given name  = Jane,
        family name = Water,
        language    = {English},
        comment     = {Something else}
    }
}

% Justine Random
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/JustineID/.style={
        female,
        nationality = french,
        given name  = Justine,
        language    = {French, English},
%       family name = Random,
        comment     = {Something interesting}
    }
}

% Tom Water
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/TomID/.style={
        male,
        nationality = british,
        given name  = Tom,
        family name = Water,
        language    = {English},
%       comment     = {There is nothing to say}
    }
}

1 Answer 1

1

I think there is a slight misunderstanding of what the keys do. The /.is choice handler defines a choice. So you need

\pgfkeys{/gtr/database/.cd,people=#1}%

to "execute" the style. Then the nationality is stored in \nationality because you said so when dialing

nationality/.store in=\nationality,

Full example.

\documentclass{article}
\begin{filecontents}[overwrite]{test_database.tex}
% Create database

% Jane Water
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/JaneID/.style={
        female,
        nationality = british,
        given name  = Jane,
        family name = Water,
        language    = {English},
        comment     = {Something else}
    }
}

% Justine Random
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/JustineID/.style={
        female,
        nationality = french,
        given name  = Justine,
        language    = {French, English},
%       family name = Random,
        comment     = {Something interesting}
    }
}

% Tom Water
\pgfkeys{/gtr/database/.cd,
    people/.is choice,
    people/TomID/.style={
        male,
        nationality = british,
        given name  = Tom,
        family name = Water,
        language    = {English},
%       comment     = {There is nothing to say}
    }
}

\end{filecontents}

\usepackage[all]{genealogytree}

\begin{document}
    
    % Define new keys in genealogytree database
    \pgfkeys{/gtr/database/.cd,
        nationality/.store in=\nationality,
        nationality=unknown,
        given name/.store in=\givenname,
        family name/.store in=\familyname,
        language/.store in=\language
    }
    
    % Define new format for genealogytree
    \gtrDeclareDatabaseFormat{xTestFormat}
    {
        % Define box title based on nationality
        \ifdefined\nationality
        \gtrset{box={title=\nationality}}
        \fi
        % Define tcolorbox parameters based on 'nationality' key
        \tcbset{unknown/.style={colback=black!5!white,colframe=black}}
        \tcbset{french/.style={colback=blue!5!white,colframe=blue}}
        \tcbset{british/.style={colback=red!5!white,colframe=red}}  
    }
    { % Define informations to print in the box
        \gtrPrintSex~\textcolor{blue}{\textbf{\givenname}}
        
        \ifdefined\familyname
        \familyname
        \fi
        
        \language
        
        \gtrifcommentdefined{\gtrPrintComment}{}
    }
    
    \input{test_database}
    
    % Create a command to print people complete data
    \newcommand\PrintCompletePeople[1]{
            
        This is the direct output: #1
        
        I want to know what is behind the key:      
        \pgfkeys{/gtr/database/.cd,people=#1}%
        \nationality
    }
    
    
    \begin{tikzpicture}
        
        \genealogytree[
            timeflow=down,
            processing=database,
            database format=xTestFormat,
            box={\nationality}
        ]
        {child[id=fam_Water]{
            p[id=Justine]{people=JustineID}
            g[id=Tom]{people=TomID}
            c[id=Jane]{people=JaneID}
            }
        }
        
    \end{tikzpicture}

    \newpage
    
    \PrintCompletePeople{JaneID}
    
    
    
\end{document}

enter image description here

1
  • Thank you for the explanation, it makes everything much more clear!
    – AlMa
    Nov 9, 2020 at 7:48

You must log in to answer this question.

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