
계보에 쓸 정보가 많아요. 그 중 일부를 가계도에 쓰고 나머지는 사람 이름을 클릭하면 볼 수 있는 다음 페이지에 쓰고 싶습니다.
패키지로 트리가 생성되고 genealogytree
데이터는 별도의 파일에 저장됩니다.test_database.tex.
\newcommand
데이터베이스에서 데이터를 인쇄하기 위해 생성하려고 했지만 아무것도 인쇄되지 않습니다. 누군가 새 명령에 인수를 올바르게 전달하는 방법을 설명해 줄 수 있습니까?
최종 목표는 데이터를 인쇄하기 위해 새로 정의된 명령에 각 이름을 입력하지 않고 이상적으로는 모든 사람의 데이터를 인쇄하는 것입니다.
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
키의 기능에 대해 약간의 오해가 있는 것 같습니다. 핸들러 /.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}