0

The code

\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,
                                   }

raises the error

! Incomplete \iffalse; all text was ignored after line 107. \fi

Is there something obvious (I'm learning) I'm missing?

0
3

colback wants a color specification, which \ifthenelse{1=1}{black!10!white}{white} isn't. It appears to be, but the \ifthenelse construct doesn't work by “pure expansion”.

Use a different boolean expression manager, such as etoolbox: after \usepackage{etoolbox} constructs such as

colback=\ifnumcomp{1}{=}{1}{black!10!white}{white}

as well as

colback=\variableBackgroundColor

with \newcommand{\variableBackgroundColor}{\ifnumcomp{1}{=}{1}{black!10!white}{white}} will work.

The admissible relations are <, = or >. See the etoolbox manual for more information.

\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}
2
  • Thanks @egreg, you're very helpful. I hope etoolbox manages also \or, etc. What is the ultimate tool for tests in LaTeX?
    – Colas
    Sep 27 '18 at 9:50
  • 2
    @Colas etoolbox allows boolean expressions; personally, I'd use expl3, but it requires a bit of study.
    – egreg
    Sep 27 '18 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.