Распечатать содержимое .unknown \pgfkeys

Распечатать содержимое .unknown \pgfkeys

У меня много информации для внесения в генеалогическое дерево. Я хотел бы часть ее внести в дерево, а остальное — на следующую страницу, доступную при нажатии на имя человека.

Дерево создается вместе с пакетом genealogytree, а данные сохраняются в отдельном файле.test_database.tex.

Я пытался создать \newcommandдля печати данных из базы данных, но ничего не печатается. Может кто-нибудь объяснить мне, как правильно передавать аргументы в новую команду?

Конечной целью является распечатка данных по всем людям, в идеале без ввода каждого имени в новой команде для печати его данных.

МВЭ

тест.текс

\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

Я думаю, что есть небольшое недопонимание того, что делают клавиши. Обработчик /.is choiceопределяет выбор. Поэтому вам нужно

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

"выполнить" стиль. Затем национальность сохраняется, \nationalityпотому что вы так сказали при наборе

nationality/.store in=\nationality,

Полный пример.

\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}

введите описание изображения здесь

Связанный контент