I have this code which produces a table with maximum width:
\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}
%table
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\tcbset
{
tab2/.style=
{
enhanced,
fonttitle=\bfseries,
fontupper=\normalsize\sffamily,
colback=white!10!white,
colframe=red!50!black,
colbacktitle=Salmon!40!white,
coltitle=black,center title
}
}
\newtcolorbox{mytable}[3][]
{
tab2,
tabularx*={\renewcommand{\arraystretch}{1.7}}{#2},
title=Table \ref{#3},
%hbox,
before={\begin{table}[htb]\refstepcounter{table}\label{#3}},
after={\end{table}},
#1
}
\begin{document}
\begin{mytable}{Y|Y}{kk}
group & one \\\hline
red & 1000.00 \\\hline
green & 2000.00 \\\hline
blue & 3000.00 \\\hline
sum & 6000.00
\end{mytable}
\end{document}
But I want the table to have the minimum width. So I added hbox
option. But it produced this error:
! Argument of \TX@get@body has an extra }.
How can I configure this table to have the minimum width?