Does pgfkeys have some some predefined handler to store unknown keys and their values in a command as a list? E.g. in the following example I would like to get a command which contains blub=1, bla=\textbf{2}. (I want to pass the unknown keys to \includegraphics).


\pgfqkeys{/my key}{


\pgfkeys{/my key/.cd, x=2, blub=1, bla=\textbf{2}}
  • Does there exist a pre-defined list of “unknown” keys that are allowed for storing in that list command? Other than that you might just add (expanded once) \pgfkeyscurrentname and \pgfkeyscurrentvalue to that list? Of course, any misspelled or really unknown key will be forwarded too. – Qrrbrbirlbel Jun 19 '13 at 16:58
  • @Qrrbrbirlbel: I simply want to forward every unknown key to \includegraphics. If the list contains a key which \includegraphics doesn't know it should give the normal error messages. With xkeyval I would use \XKV@rm. – Ulrike Fischer Jun 19 '13 at 17:04

Maybe something along these lines?

The handler .unknown to list installs an .unknown/.code key that appends the unknown key and possibly its given value (enclosed in { }) to the list #1. An additional .@clear list key is used to clear the list #1, though if the keys are executed inside a group (as with TikZ on paths) there shouldn’t be much use for it, I guess.

The \pgfutil@gobble (which apparently isn’t available with pgfkeys) removes the first , from the list. (Of course, is the solution is only intended for LaTeX, the usual \@gobble can be used anyway.)

The amount of \expandafters simulates a \expandonce/\appto combo (etoolbox) because we can’t assume everything is expandable (and should be expanded at all).


\pgfkeys{/handlers/.unknown to list/.code=%
  \pgfkeysalso{% or \pgfkeys{\pgfkeyscurrentpath/.cd,
    .unknown/.code=% how to handle the difference between 'key' and 'key=value'?
     .@clear list/.code=\let#1\pgfutil@gobble}%

\pgfkeys{/my key/.cd,
 .unknown to list=\myList
  /my key/.cd,
  dingenskirchen=something else


\pgfkeys{/my key/.@clear list}



enter image description here

  • This works and give the expected output. In the meantime I also found a solution using filtered keys but I don't like it (to much install filter and handlers involved). I think I will revert to my other idea: Giving the keys not known to includegraphics some default meaning. – Ulrike Fischer Jun 20 '13 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.