I'd like to store tcolorbox
' (multiple) settings in a (single) macro (in fact, a xkeyval
's \cmdKV@fam@key
macro) and use them afterwards via this macro (I know I should use pgfkeys
instead, but my whole class is using xkeyval
). Probably because of a pgfkeys
expansion trouble, I can't succeed: for instance, colback=red
is a regular option of the tcolorbox
's tcolorbox
environment, but it can't be stored in a macro, as pointed out by the following MWE (which involves only a single setting for simplicity):
\documentclass{article}
\usepackage{tcolorbox}
%
\newcommand*\foo{colback=red}
%
\begin{document}
\begin{tcolorbox}[\foo]
Test.
\end{tcolorbox}
\end{document}
which leads to the following error:
! Package pgfkeys Error: I do not know the key '/tcb/colback=red'
How could I circumvent this problem?
xkeyval
; however,\tcbset{foo/.style={colback=red}}
and\begin{tcolorbox}[foo]
does the trick. You'd have the same problem withxkeyval
, as it doesn't expand the tokens passed in\setkeys
.