Due to scoping, the keys you set inside the minipage
are only defined inside this environment. Therefore, you would need to define the key outside of the environment or define it gobally somehow.
You could apply the approach in this answer and create a global version of the \pgfkeys
macro. However, this approach is probably risky because everything \pgfkeys
does internally will be global. This may lead to unintended results in certain cases and break other code (thanks to Skillmon and David Carlisle for pointing to this).
For very simple assignments, you could maybe also use \global\pgfkeyslet
, but using this approach, things like .initial
would not be applicable. Also, the same warning as above applies here. So, do not use this if you plan to have others use your code!
I'd recommend, therefore, to restructure the logic of your document and define the keys outside of the environment.
\documentclass{article}
\usepackage{tikz}
%%% not recoomended!
\newcommand\gpgfkeys[1]{%
\begingroup%
\globaldefs=1\relax%
\pgfkeys{#1}%
\endgroup%
}
%%%
\begin{document}
\pgfkeys{aaa/.initial=aaa}
\noindent
\begin{minipage}{1.0\linewidth}
\def\mybbbkey{bbb} %%%
\global\pgfkeyslet{/bbb}{\mybbbkey} %%%
%%%
\gpgfkeys{ccc/.initial=ccc} %%% not recommended!
Inside minipage, the value of the key "aaa" is \pgfkeysvalueof{/aaa} \\
Inside minipage, the value of the key "aaa" is \pgfkeysvalueof{/bbb} \\
Inside minipage, the value of the key "ccc" is \pgfkeysvalueof{/ccc}
\end{minipage}
\bigskip
\noindent
Outside minipage, the value of the key "aaa" is ---\pgfkeysvalueof{/aaa}--- \\
Outside minipage, the value of the key "bbb" is ---\pgfkeysvalueof{/bbb}--- \\
Outside minipage, the value of the key "ccc" is ---\pgfkeysvalueof{/ccc}---
\end{document}

\def
inside theminipage
.{\def\hello{hello}} \hello
. In your case, you would need to assign the key gloablly (or outside of the scope). See: tex.stackexchange.com/q/15204/47927document
avoids a group for technical reasons, but as the LaTeX run ends with\end{document}
is this not really an issue.)pgfkeys
has no provisions to set keys globally. It is recommended to instead move the keys definition to the global scope (usually the document preamble).