抱歉,这肯定是初学者的难题,但我不知道如何在循环中展开宏。我试过 expandafter、csname,但没有成功。
\documentclass[]{minimal}
\usepackage{xkeyval}
\usepackage{pgffor,pgfmath}
\makeatletter
\define@cmdkey[mini]{test}{keyA} {}%
\define@cmdkey[mini]{test}{keyB} {}%
\define@cmdkey[mini]{test}{keyC} {}%
\newcommand{\testMacro}[1][]
{%
\setkeys[mini]{test}{#1}%
\cmdmini@test@keyA% these work ok
\cmdmini@test@keyB%
\cmdmini@test@keyC%
\foreach \i in {A,B,C}{%
\i :%
\cmdmini@test@key{\i}% This is the line that goes wrong
}
}
\makeatother
\begin{document}
\testMacro[%
keyA={this is key A},%
keyB={this is key B},%
keyC={this is key C},%
]
\end{document}