
Tenho muitas informações para escrever em uma árvore genealógica. Gostaria de escrever parte na árvore e o restante na próxima página, acessível ao clicar no nome da pessoa.
A árvore é criada com o pacote genealogytree
e os dados são armazenados em um arquivo separadotest_database.tex.
Tentei criar um \newcommand
para imprimir dados do banco de dados mas nada é impresso. Alguém pode me explicar como passar os argumentos corretamente para o novo comando?
O objetivo final é imprimir os dados de todas as pessoas, de preferência sem digitar cada nome no comando recém-definido para imprimir seus dados.
MWE
teste.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}
}
}
Responder1
Acho que há um pequeno mal-entendido sobre o que as chaves fazem. O /.is choice
manipulador define uma escolha. Então você precisa
\pgfkeys{/gtr/database/.cd,people=#1}%
para "executar" o estilo. Então a nacionalidade é armazenada \nationality
porque você disse isso ao discar
nationality/.store in=\nationality,
Exemplo completo.
\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}