I want to create a command that can change the default value of my pgfkeys. I think the problem is that the value set as default is not expanded. Therefore the icondefaultsa
below doesn't work. Therefore I made icondefaultsb
, which works. The drawback is that the global variables \width
and \overlay
are created, and changing them also changes the default values of the pgfkeys.
\pgfkeys{
/icon/.cd,
width/.initial = ,
width/.default = ,
overlay/.initial = ,
overlay/.default = ,
width,overlay,
}
\newcommand\icondefaultsa[1]{%
\pgfkeys{/icon/.cd,#1}%
\pgfkeys{
/icon/.cd,
width/.default = \pgfkeysvalueof{/icon/width},
overlay/.default = \pgfkeysvalueof{/icon/overlay},
width,overlay,
}%
}
\newcommand\icondefaultsb[1]{%
\pgfkeys{/icon/.cd,#1}%
\pgfkeysgetvalue{/icon/width}{\width}%
\pgfkeysgetvalue{/icon/overlay}{\overlay}%
\pgfkeys{
/icon/.cd,
width/.default = \width,
overlay/.default = \overlay,
width,overlay,
}%
}