How can I resolve an xkeyvalue from a definition? The code


\define@key{mykeys}{foo}[foo-default]{\def\x{Key 'foo' does nothing}}


fails because foo,bar=key is not recognized as two keys, but only as one key. In other words, xkeyval does not recognize the comma between the keys foo and bar=key. How can I make xkeyval identify the comma correctly?


2 Answers 2


\setkeys does not expand its second argument, but the error message does so sometimes it's puzzling.

You can define a \setkeysexpanded command:




will work.

The double argument switching is to ease the use of \expandafter.

  • Thanks! I already thought my problem had to do with expansions, but I cound not figure it out correctly. Would it also be possible to achieve this without any auxiliary commands? Mar 11, 2013 at 0:02
  • @SimonReich One could redefine \setkeys, but I wouldn't recommend it. Better keeping the things well separated. However, \setkeysexpanded works also with normally specified options.
    – egreg
    Mar 11, 2013 at 0:04
  • Alright, this solution works perfectly well. Mar 11, 2013 at 0:04
  • @SimonReich Welcome to TeX.sx!
    – egreg
    Mar 11, 2013 at 0:05

Please accept egreg's answer. Another approach is to define a special key set list that you then use to set a key-value list:

\define@key{mykeys}{set list}{%
  \edef\x{Key 'foo' with value '\detokenize{#1}' does nothing}%
  \edef\x{Key 'bar' with value '\detokenize{#1}' does nothing}%
\setkeys{mykeys}{set list=\kvlist}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .