I make up a macro \allcw which contains some definition of raster column width style like this:
raster column 1/.style={width=2em},
raster column 2/.style={width=6em},
raster column 3/.style={width=12em}
Please see my code below. But it does not be compiled? What's wrong with my code?
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{xstring}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\columnwidthlist{2em,6em,12em,}
\newcounter{step}
\newcommand{\allcw}{%
\setcounter{step}{0}
\def\mystore{}
\foreach \x in \columnwidthlist {
\stepcounter{step}
\IfStrEq{\x}{}{}
{%
\xappto\mystore{
raster column \thestep/.style=\{width=\x\},
}
}
}
\tcbset{cwall/.style={code={\pgfkeysalsofrom{\mystore}}}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tcbitemize}[raster columns=3,raster force size=false,code={\allcw},cwall]
\tcbitem some text
\tcbitem some text
\tcbitem some text
\tcbitem some text
\tcbitem some text
\tcbitem some text
\end{tcbitemize}
\end{document}


\foreach \x in columnwidthlistdoesn't work becausecolumnwidthlistis just a string, not a list. If you replace that by\foreach \x in \columnwidthlist, there is still an error (perhaps unrelated), but the loop works. – Oct 10 '18 at 14:22