代码
\newcommand{\variableBackgroundColor}{%
\ifthenelse{1=1}%\(\boolean{Colle} \OR \boolean{DM}\)}
%then
{black!10!white}
%else
{white}
}
\tcolorboxenvironment{private_exo}{boxrule=0pt,
colframe=white,
colback=\variableBackgroundColor,
breakable,
top=0pt,
bottom=0pt,
left=0pt,
right=0pt,
left skip=0pt,
right skip=0pt,
boxsep=0pt,
sharp corners,
noparskip,
nobeforeafter,
%parbox=false,
}
引发错误
! 不完整 \iffalse;第 107 行之后的所有文本均被忽略。\fi
我是否遗漏了一些明显的知识(我正在学习)?
答案1
colback
想要颜色规范,但颜色规范\ifthenelse{1=1}{black!10!white}{white}
没有。出现但这种\ifthenelse
构造并不能通过“纯扩展”来实现。
使用不同的布尔表达式管理器,例如etoolbox
:在\usepackage{etoolbox}
构造之后
colback=\ifnumcomp{1}{=}{1}{black!10!white}{white}
也
colback=\variableBackgroundColor
可以\newcommand{\variableBackgroundColor}{\ifnumcomp{1}{=}{1}{black!10!white}{white}}
。
允许的关系是<
,=
或>
。etoolbox
有关更多信息,请参阅手册。
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{etoolbox}
\newcommand{\variableBackgroundColor}{%
\ifnumcomp{1}{=}{1}{black!10!white}{white}%
}
\newenvironment{private_exo}{}{}
\tcolorboxenvironment{private_exo}{
boxrule=0pt,
colframe=white,
colback=\variableBackgroundColor,
breakable,
top=0pt,
bottom=0pt,
left=0pt,
right=0pt,
left skip=0pt,
right skip=0pt,
boxsep=0pt,
sharp corners,
noparskip,
nobeforeafter,
%parbox=false,
}
\begin{document}
\begin{private_exo}
abc
\end{private_exo}
\end{document}