TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to be able to alias a PGF key to another name, is this possible and if it is, how do I do this?

For example if I have defined a key as:

    color/.store in=\color@cx

I would like have the ability to let "color" to "somecolor" would it also be possible to alias keys that have been defined using .style?

share|improve this question
In this particular example, whenever you refer to it with color=somecolor it would be stored in \color@cx. Which one do you want to access later with alias? There is /.link key but I don't know if that's what you are after. – percusse Apr 9 '12 at 10:27
@percusse I would like both to point to the same macro color->color@cx and somecolor->color@cx. – Yiannis Lazarides Apr 9 '12 at 10:42
They can both be appointed to execute the same /.code. For example, \pgfkeys{setmycolor/.code={\color@cx=#1}}\/pgfkeys{color/.style={setmycolor=blu‌​e}}\pgfkeys{somecolor/.style={setmycolor=red}}. – percusse Apr 9 '12 at 10:51
up vote 6 down vote accepted

The approach I usually employ is to use a .code handler that just executes \pgfkeysalso on the alias target:

\pgfkeys{other path/somecolor/.code={\pgfkeysalso{path/color=#1}}

However, as I have learned from Christian Feuersänger, this is exactly how the .style handler is defined in pgfkeys. So an even cleaner solution is:

\pgfkeys{/other path/somecolor/.style={path/color=#1}}
share|improve this answer
Note that this is 100% equivalent to other path/somecolor/.style={path/color=#1}. This is because /.style is defined by means of \pgfkeysalso (just as you did). An "alias" in this sense is a style. – Christian Feuersänger May 11 '12 at 20:30
@ChristianFeuersänger:Thanks for the info; I have edited this into the answer. – Daniel May 11 '12 at 21:10
I added a missing closing brace to Daniel's second solution. – Ahmed Musa May 11 '12 at 23:58
@Daniel I would appreciate your comments on the code I posted --still finding my way around pgf:) . – Yiannis Lazarides Jun 6 '12 at 13:48

I have expanded on Daniel's idea and used handlers to define a handler called .alias. The code is shown below:

% alias key
      /handlers/.alias/.value required,%

\pgfkeys{test/.store in=\storethis,


\pgfkeys{test=this is a test}
share|improve this answer
I don't know pgfkeys well, but what is the name/macro \pgfkeyscurrentpath/.@blank supposed to do? – Ahmed Musa Jun 6 '12 at 16:03
Good idea, way more PGFish :-) I probably would reverse the syntax and make .alias a handler that is executed on the key to link to (test/.alias=tes) instead of the alias, as this seems more natural to me (reflects the order of parameters to ln -s on UNIX) – Daniel Jun 6 '12 at 20:47
@AhmedMusa It creates a handler to provide a value for the empty case i.e, test/.default=default, test/.blank=this is blank, will print for test default and for test= will give this is blank. Not related to the question, but thought could be useful to leave it in. – Yiannis Lazarides Jun 6 '12 at 23:06
@Daniel Thanks, agreed on the reverse. – Yiannis Lazarides Jun 6 '12 at 23:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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