我想根据宏名动态显示不同的内容,通过以下方式无法实现:
\begin{filecontents*}{\jobname.csv}
x`list
A`Macroone,Macrotwo
\end{filecontents*}
\documentclass{article}
\usepackage{xparse}
\usepackage{datatool}
\usepackage{xstring}
\usepackage{forarray}
\usepackage{ctex}
\DTLsetseparator{`}
\DTLloaddb{tabscores}{\jobname.csv}
\DTLgetvalue{\score}{tabscores}{1}{2}
\newenvironment{Macroone}[1]{Column1<t>Column 2 and param is #1}{}
\newenvironment{Macrotwo}[1]{Column1<t>Column 2 and param is #1}{}
%Get the parameter to replace the character,but did not succeed
\newcommand{\testprintstring}[1]{
\noexpandarg
\expandafter\StrSubstitute\expandafter{#1}{<t>}{`}[\item]
\item %<T> is not replaced by `
}
\begin{document}
%Retrieve the corresponding content as a parameter based on the macro name
\ForEachX{,}{
\testprintstring{\begin{\thislevelitem}{param}\end{\thislevelitem}}
}{\score}
\end{document}
结果是:Column1Column 2 and param is param Column1Column 2 and param is param