Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way to iterate over all PGF keys that have been defined previously? My idea is to capture the value of all keys in order to do Proper nesting of tikzpicture environments: Reset all PGF values to their defaults.

EDIT: I imagine something along these lines:



I wouldn't mind if recording and restoring would use a temporary file.

share|improve this question
add comment

1 Answer

There is no such feature (and it would be way too expensive).

If you need it, you have to record all options "in scope" manually (and you would need to define clearly what "in scope" means).

One way to record options might be the key filtering ability of pgfkeys (which is quite advanced, however).

share|improve this answer
I have enhanced my question a bit. Do you think key filtering could help here? –  krlmlr Apr 5 '12 at 13:01
I think an option is to use a macro for setting the keys in the first place \def\setkeysdefault{\pgfkeysset{...}} then is easy to have them reset. Is this a good option? –  Yiannis Lazarides Apr 5 '12 at 13:04
Who would have to implement/maintain \setkeysdefault? –  krlmlr Apr 5 '12 at 15:40
Collecting/saving defined pgf keys should presumably be cheaper than in the case of ltxkeys. In ltxkeys there is a way to iterate over all defined ltxkeys that have been previously defined. Yes, it is expensive but not too expensive. All defined keys and their default/initial values are available at any time in the macro \<prefix>@<family>@intialkeyvalues. This is used to recover all default values of keys at once and to, if needed, reinitialize keys (ie, reset keys to their default values) at any time. –  Ahmed Musa Apr 5 '12 at 17:01
@Ahmed thanks for the note. However, considering the fact that pgf and its child packages rely heavily on the keyvalue interface, I would refrain from activating such a feature by default (perhaps because I do not understand the use-case completely). But you can surely write some sort of custom library which does it. –  Christian Feuersänger Apr 6 '12 at 9:14
show 2 more comments

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.