7

The package TASKS is very useful for horizontal lists. However, when using Tasks lists inside TColorBoxes, Tasks behaves oddly, adding carriage returns when not necessary. Is there a way to restore a normal behavior to Tasks ?

\documentclass[]{book}
\usepackage{tcolorbox}
\usepackage{tasks}
\begin{document}

\tcbset{MyTasksInTColorBox/.style={
colframe=blue!70!black,
colback=blue!2!white,
fonttitle=\bfseries\huge
}}

\settasks{
label-format={\color{green!70!black}\large\bfseries},
}

\def\ContentOfBox{%
%
\bfseries Tasks in 3 columns \normalfont
\begin{tasks}[style=multiplechoice](3)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\noindent\rule{2cm}{0.4pt}\\[2mm]
%
\bfseries Tasks in 4 columns \normalfont
\begin{tasks}[style=multiplechoice](4)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\noindent\rule{2cm}{0.4pt}\\[2mm]
%
\bfseries Tasks in 5 columns \normalfont
\begin{tasks}[style=multiplechoice](5)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\noindent\rule{2cm}{0.4pt}\\[2mm]
%
\bfseries Tasks in 6 columns \normalfont
\begin{tasks}[style=multiplechoice](6)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\noindent\rule{2cm}{0.4pt}\\[2mm]
%
\bfseries Tasks in 7 columns \normalfont
\begin{tasks}[style=multiplechoice](7)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
}

\begin{tcolorbox}[MyTasksInTColorBox,title= {Tasks in (4) and (5) columns have a carriage return issue  (width = linewidth)}]
\ContentOfBox
\end{tcolorbox}


\begin{tcolorbox}[MyTasksInTColorBox,width=1.1\linewidth,title= {Tasks in (5) and (7) columns have a carriage return issue (width = 1.1*linewidth)}]
\ContentOfBox
\end{tcolorbox}


\begin{tcolorbox}[MyTasksInTColorBox,width=1.2\linewidth,title= {Tasks in (5) and (6) columns have a carriage return issue (width = 1.2*linewidth)}]
\ContentOfBox
\end{tcolorbox}


\begin{tcolorbox}[MyTasksInTColorBox,width=1.3\linewidth,title= {Tasks in (4), (5), (6) and (7) columns have a carriage return issue (width = 1.3*linewidth)}]
\ContentOfBox
\end{tcolorbox}


\end{document}

enter image description here enter image description here enter image description here enter image description here

1
  • I removed the 2nd question. The \raggedbottom is unecessary if tcolorbox is not loaded.
    – SDrolet
    May 22, 2018 at 17:27

1 Answer 1

4

Section 4.18 of the tcolorbox manual (Version 4.21) discusses the parbox= setting:

The text inside a tcolorbox is formatted using a LATEX minipage if the box is unbreakable. If breakable, the box tries a mimicry of a minipage. In a minipage or parbox, paragraphs are formatted slightly different as the main text. If the key value is set to false, the normal main text behavior is restored. In some situations, this has some unwanted side effects. It is recommended that you use this experimental setting only where you really want to have this feature.

Thus, using parbox=false should restore normal formatting.

I also included left=pt and right=0pt to eliminate the padding on the left and right

\tcbset{MyTasksInTColorBox/.style={
    colframe=blue!70!black,
    colback=blue!2!white,
    fonttitle=\bfseries\huge,
    parbox=false,
    left=0pt,
    right=0pt,
}}

enter image description here enter image description here enter image description here enter image description here

1
  • 1
    +1, I have been waiting for this answer for months!
    – CarLaTeX
    Sep 25, 2019 at 7:44

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.