TeX - LaTeX Asked by AlMa on February 21, 2021
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
ifdefinednationality
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}}
ifdefinedfamilyname
familyname
fi
language
gtrifcommentdefined{gtrPrintComment}{}
}
input{test_database}
% Create a command to print people complete data
newcommandPrintCompletePeople[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}
}
}
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
ifdefinednationality
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}}
ifdefinedfamilyname
familyname
fi
language
gtrifcommentdefined{gtrPrintComment}{}
}
input{test_database}
% Create a command to print people complete data
newcommandPrintCompletePeople[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}
Correct answer by user228539 on February 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP