# Combine code for synonym-keys in pgfkeys

I use pgfkeys to define package options, one of them regulates the color of some items. I have multiple keys, defining the same code, e.g. colors=1 or colors=b&w.

Do I have to repeat the code part for the second key or is it possible to define a "synonym"? If yes, how?

My code snippet:

\def\Keyset#1{\pgfkeys{/MyKey,#1}}

\Keyset{colors/.is choice,}

\Keyset{colors/1/.code={...}}

\Keyset{colors/b&w/.code={Same code as with 1}}

• Don't use & character. \Keyset{colors/bw/.code={\pgfkeys{/Mykey/colors=1}} – percusse Mar 9 '18 at 10:36
• I searched the docs and the internet to find the & issue. As I found nothing I just tried it, To my surprise it worked. Why should an & not be used in this case? – Jack Mar 9 '18 at 11:07
• It usually works because PGF uses key names inside \csname and \endcsname pair. But when it rarely breaks down it is such a major pain in the ass to find the reason. That's why it's better to be safe than sorry. – percusse Mar 9 '18 at 11:23