4

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:

\documentclass{article}
\beginrecordallpgfkeys
\usepackage{tikz}
\endrecordallpgfkeys

\begin{document}
  \restoreallrecordedpgfkeys
\end{document}

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

1 Answer 1

7

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).

7
  • I have enhanced my question a bit. Do you think key filtering could help here?
    – krlmlr
    Apr 5, 2012 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?
    – yannisl
    Apr 5, 2012 at 13:04
  • Who would have to implement/maintain \setkeysdefault?
    – krlmlr
    Apr 5, 2012 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, 2012 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. Apr 6, 2012 at 9:14

You must log in to answer this question.

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