I would like to use pgfkeys in a macro. One key contains a foreach statement which handles a variable number of values. I have some problems concerning the right order of the output. Here a simplified example:
\documentclass[article]{memoir}
\usepackage[latin]{babel}
\usepackage{algpseudocode}
\usepackage{pgfkeys}
\pgfkeys{%
/test/.is family,
/test/.cd,
key a/.store in = \keyA,
key a print/.code = \texttt{\keyA},
key b/.code = {\foreach \x in {#1}{\textbf{\x}--}}
}%
\newcommand\mymacro[1]{\pgfkeys{/test, #1, key a print}}
\begin{document}
\mymacro{key a = valueKeyA, key b = {valueKeyB1, valueKeyB2, valueKeyB3}}
\end{document}
The order of the output is: valueKeyB1–valueKeyB2–valueKeyB3–valueKeyA
How can I achieve that valueKeyA is typeset first? If I put #1 at the end of the key list in my example code I get an error message. If I place it at the end of the key list in my actual code the values of the first keys are missing. I guess it has either something to do with the order in which the values are stored and the keys are executed or my use of #1 is mixed up.
I am using pgfkeys for a short time and would be glad if someone could give me a hint.