I want to define some options as a list of key-value pairs inside a macro and use that macro inside a command that takes pgfkeys-style options. Here is a MWE:
\documentclass{standalone}
\usepackage{pgfkeys}
\pgfkeys{
/example/.is family, /example,
.unknown/.code = {
(\pgfkeyscurrentkeyRAW,#1)
\typeout{DEBUG \pgfkeyscurrentkeyRAW}
}
}
\newcommand{\defvalues}[2][]{
\pgfkeys{/example, #1}
}
\begin{document}
\def\mylist{c=3,d=4}
\defvalues[a=1,b=2]{}
\expandafter\defvalues\expandafter[\mylist]{}
\expandafter\defvalues\expandafter[f=6,\mylist]{}
\end{document}
In the last line, \mylist
is not expanded correctly.
Expected output in the document:
(a,1) (b,2) (c,3) (d,4) (f,6) (c,3) (d,4)
Actual output:
(a,1) (b,2) (c,3) (d,4) (f,6) (c=3,d=4)
Alternatively, when running pdflatex test.tex|grep DEBUG
, expected output:
DEBUG a
DEBUG b
DEBUG c
DEBUG d
DEBUG f
DEBUG c
DEBUG d
Actual output:
DEBUG a
DEBUG b
DEBUG c
DEBUG d
DEBUG f
DEBUG c=3,d=4
How do I get \mylist
to expand before it is passed to pgfkeys
?
.style
handler to define your list:\pgfkeys{/example/mylist/.style={a=1,b=2}}
.\mylist
) in advance? I'd like to provide everything you see in the preamble as a package.