This question represents a second, more simplified, attempt at a problem I asked about some time ago but for which I received no answer.
In short, I need to put the fully expanded result of a call to \pgfkeys
in a macro for later use, and the key path itself contains macros. The purpose is that I have parameters which change depending on the type and part of the document one is in, and I want to have a single call to \pgfkeys
(which will appear in the definitions of other macros/environments) automatically look up the right parameter for the currently active settings.
I tried using .estore in
, but got the error TeX capacity exceeded, sorry [input stack size=5000]
.
Using .store in
lets me set the key, but since the macro contains the unexpanded \pgfkeys
function, I can't use it in a context like the argument to another macro/environment, and I haven't been able to figure out how to expand it before calling another macro. (In my various experiments with \edef
, I usually wind up with unending compilation.) In the MWE, opening the multicols
environment with the macro defined this way causes the error !Missing number, treated as zero
.
So, how can get a fully expanded value into a macro set by \pgfkeys
when the right side of the assignment is itself a call to \pgfkeys
?
My preference is a solution that still lets me use \pgfkeys
rather than \pgfkeysvalueof
or some other key-value package, because I make heavy use of the .search also
handler, but at this point I'm willing to consider other approaches, including l3keys
, even if it requires a massive rewrite elsewhere.
MWE:
\documentclass{article}
\usepackage{pgfkeys}
\usepackage{multicol}
\newcommand{\ActiveFormat}{generic}
\newcommand{\ActiveDomain}{default}
\newcommand{\colnum}{1}
\pgfkeys{/stdt/.cd,
num-columns/.store in=\colnum,
% num-columns/.estore in=\colnum,
generic/default/num-columns/.initial=2,
}
\begin{document}
\textbackslash colnum = \colnum
\pgfkeys{/stdt/num-columns=\pgfkeys{/stdt/\ActiveFormat/\ActiveDomain/num-columns}}
% This is fine with the .sore in version
\textbackslash colnum = \colnum
% There will be an error here
\begin{multicols}{\colnum}
Some text.
Some more text.
\end{multicols}
\end{document}