I have a problem with tabularx
in a tcolorbox
environment, here is the code:
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[most]{tcolorbox}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}
\begin{document}
\newcolumntype{b}{X}
\newcolumntype{i}{>{\hsize=.005\hsize}X}
\newcolumntype{s}{>{\hsize=.15\hsize}X}
\begin{table}
\begin{center}
\begin{tcolorbox}[colback=black!0.8!white,colframe=black!4!white,
colbacktitle=gray!40!white, coltitle=black,width=1.0\linewidth,tabularx={ibs}]
\multicolumn{2}{b}{Number} & 11 \\\hline
& part a & 38 \\\hline
& part b & 4 \\\hline
& part c & 2 \\\hline\hline
\multicolumn{2}{l}{Blabla 1} & 217 \\\hline
\multicolumn{2}{l}{Blabla 2} & 20 \\\hline
\multicolumn{2}{l}{Blabla 1} & 105 \\\hline
\multicolumn{2}{l}{Blabla 1} & 3100 \\\hline
\multicolumn{2}{l}{Blabla 1} & 367
\end{tcolorbox}
\end{center}
\end{table}
\vspace{3cm}
\begin{center}
\begin{tabularx}{1.0\linewidth}{ibs}
\multicolumn{2}{b}{Number} & 11 \\\hline
& part a & 38 \\\hline
& part b & 4 \\\hline
& part c & 2 \\\hline\hline
\multicolumn{2}{l}{Blabla 1} & 217 \\\hline
\multicolumn{2}{l}{Blabla 2} & 20 \\\hline
\multicolumn{2}{l}{Blabla 1} & 105 \\\hline
\multicolumn{2}{l}{Blabla 1} & 3100 \\\hline
\multicolumn{2}{l}{Blabla 1} & 367\end{tabularx}
\end{center}
\vspace{3cm}
\end{document}
In a regular tabularx
environment, the table is okay (see 2nd table). However, if I do the same in a tcolorbox
environment (1st table), the first line, which contains a multicolumn
, does not work, whereas the other 5 show up, if one passes all the errors.
The error is (appears 6x):
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.31 \end{tcolorbox}
?
I tried to play with the 'size' of the first multicolumn but did not succeed.
Any help is highly appreciated. Thanks.
ibs
heading is wrong , you have 3 X columns so the total width should be 3\hsize and 1+.005+.15 is not 3, tabularx will most likely fail to converge to sensible size given that input.