I'm using pgfkeys
to define some key-value options. I need some default value to initialize a key and I also want to use this default value as a fallback indepentent from the passed key value pair.
What I've tried is to create somekind of a child key. But I don't know how to use this to initialize the actual key with it.
In the MWE at the workaround I would like to use the original initialized value for titlepage. What is the best way to achieve this?
\begin{filecontents}{\jobname.def}
Test file content
\end{filecontents}
\documentclass{article}
\usepackage{pgfkeys}
\pgfkeys{
test/.cd,
titlepage/.store in = \@file@titlepage,
titlepage/.default = \jobname.def,%<-- Set default value
titlepage = \jobname.def, % <-- initial titlepage
}
\newcommand{\testtitlepage}{%
\InputIfFileExists{\@file@titlepage}
{Found titlepage: \@file@titlepage\par} % <-- only for testing}
{Workaround: \pgfkeysvalueof{test/titlepage}}%<-- Try to use default value of titlepage
}
\begin{document}
\pgfkeys{test/titlepage = test.def}% <-- Set non-existing file to activate workaround
\testtitlepage
\end{document}
Edit:
I updated my MWE to use .default
. But I'm still unable to use this default key inside \testtitlepage, when the passed file don't exist.
pgfkeys
modifiers.default
or.initial
are meant for?.default
modifier. But I still don't know how to get this default value inside my macro testtitlepage, when the passed file don't exist.