Consider the following MWE:
\documentclass{article}
\usepackage{tikz}
\newenvironment{env}{
\pgfkeys{/env/.initial=hello}
}{}
\newcommand{\comm}{
\pgfkeys{/comm/.initial=hello}
}{}
\begin{document}
\begin{env}\end{env}
\comm{}
\pgfkeys{
/env/.get=\envval,
/comm/.get=\commval,
}
Value of key set using environment: \envval
Value of key set using command: \commval
\end{document}
It produces
Value of key set using environment:
Value of key set using command: hello
Is this an known issue, and are there any workarounds?
pgfkeysin particular. It is the same for any other way of writing\def. – cfr Feb 08 '17 at 04:28\pgfkeysgsetvalue{/env}{Hello}, where the macro\pgfkeysgsetvalueis defined in Martin Scharrer's answer in the post I linked to above. He also defines a.gcodehandler. – Feb 08 '17 at 04:35.gset_thingin addition to.set_thing. And that seems to make it a lot easier in practice to get values assigned globally when you want them and not otherwise. I agree that the particular structure in the example would still be problematic, but something functionally equivalent is easier to create than withpgfkeys. At least, for me it is. But L3 keys makes more sense generally to me thanpgfkeysever has, so maybe I just don't see the obvious in the latter case. – cfr Feb 08 '17 at 18:19