Error when using fbox numbering with tasks package

When I insert "\renewcommand{\labelenumi}{\bfseries \fbox{\arabic*}}" in the preamble, I receive an error "! Argument of \boxframe has an extra }.\par \item" but it's good If I don't insert that. My codes are :

\documentclass{report}
\usepackage{multicol,amsmath,amsfonts,tasks,enumitem}
%\renewcommand{\labelenumi}{\bfseries \fbox{\arabic*}}
\begin{document}
\begin{center}
\textbf{EXERCISES}\\
\end{center}
\begin{enumerate}
\item Prove the following by induction on $n$, where $n\in\mathbb Z^+$.
\begin{tasks}(2)
\task $\sum_{r=0}^n 2^r=2^{n+1}-1$
\task $5+5^2+\cdots+5^n=\frac{5(5^n-1)}{4}$
\task $\sum_{r=0}^n a^r=\frac{a(a^n-1)}{a-1};~a\in\mathbb R$\\
\task The sum of the first $n$ odd numbers is $n^2$.
\task* $(1+a)+2(2+a)+3(3+a)+\cdots+n(n+a)=\frac{n}{6}(n+1)(3a+2n+1);~a\in\mathbb R$
\task* $5(4)+6(5)+7(6)+\cdots+n(n-1)=\frac{1}{3}(n^3-n-60);~\forall n\geq 5$
\task* $1^4+2^4+3^4+\cdots+n^4=\frac{n}{30}(n+1)(2n+1)(3n^2+3n-1)$
\end{tasks}
\item Prove the following statements by induction.
\begin{tasks}[counter-format={\bfseries tsk[1].}](2)
\task $\sum_{r=1}^n r^5=\frac{n^2}{12}(n+1)^2(2n^2+2n-1)$
\task $\sum_{r=1}^n \frac{1}{r(r+1)}=\frac{r}{r+1}$
\task $\prod_{r=1}^n r^{12}=(r!)^{12}$

\end{tasks}
\end{enumerate}
\end{document}


Thanks advance for your help.

1 Answer

\fbox is a fragile command, it needs to be protected in this case:

\renewcommand{\labelenumi}{\bfseries\protect\fbox{\arabic*}}

• +1 but \fbox from LaTeX is not fragile: it is package xcolor (loaded by tasks) which makes it fragile. Furthermore, this "fragile" matters in such \labelenumi due to enumitem package. Without enumitem if one does \renewcommand{\labelenumi}{\bfseries \fbox{\arabic{enumi}}} for example, there is no problem, even though \fbox is "fragile" due to xcolor.
– user4686
Jun 26, 2018 at 6:36
• and only to be complete, \protect normally would do nothing in \labelenumi. But package enumitem does give \protect its protection activity, precisely because package enumitem hacks the way labels of items are done. I hope I am not too pedantic, but this is to clarify, because in LaTeX \protect acquires its specific meaning only in certain contexts like in \section arguments. The fact that it works here is related to enumitem. The fact that it is needed is caused by xcolor.
– user4686
Jun 26, 2018 at 6:54
• I also want to use this command in \labelenumii e.g.: \renewcommand{\labelenumii}{\itshape \alph)}* in the preamble but it doesn't work. Can you help me ? Jun 26, 2018 at 8:57