I need to store some parameters in a document and later be able to retrieve them. I’m sharing the code with you:
\documentclass{article} \usepackage{tikz} \pgfkeys{ /myKeys/.is family, } \newcommand{\readDynamicKey}[1]{ \pgfkeysifdefined{/myKeys/#1}% {Value of Key #1 = \pgfkeysvalueof{/myKeys/#1}}% {Key #1 not found} } \begin{document} Reading all keys immediately after being created\\ \def\n{1} \pgfkeyssetvalue{/myKeys/A\n}{A\n} \readDynamicKey{A\n}\\ \foreach \n in {2,...,3}{ \pgfkeyssetvalue{/myKeys/A\n}{A\n} \readDynamicKey{A\n}\\ } \par\medskip Reading all keys later\\ \foreach \n in {1,...,3}{ \readDynamicKey{A\n}\\ } \end{document}
However, the compiler's response is:
Reading all keys immediately after being created Value of Key A1 = A1 Value of Key A2 = A2 Value of Key A3 = A3 Reading all keys later Value of Key A1 = A1 Key A2 not found Key A3 not found
It seems that the keys are being saved, but later I can't retrieve them. Could you help me resolve this?