In the following code
\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}}
\newcommand{\btable}[2]{\begin{table}
\refstepcounter{table}\label{#2}
\begin{tcolorbox}[tab2,tabularx*={\renewcommand{\arraystretch}{1.7}}{#1},title=Table \ref{#2},boxrule=0.8pt]}
\newcommand{\ntable}{\end{tcolorbox} \end{table}}
%end ot table commands
\begin{document}
\btable{Y|Y|Y|Y|Y|Y}{kk}
group & one & two & three & four & sum \\\hline
red & 1000.00 & 2000.00 & 3000.00 & 4000.00 & 10000.00 \\\hline
green & 2000.00 & 3000.00 & 4000.00 & 5000.00 & 14000.00 \\\hline
blue & 3000.00 & 4000.00 & 5000.00 & 6000.00 & 18000.00 \\\hline
sum & 6000.00 & 9000.00 & 12000.00 & 15000.00 & 42000.00
%\end{tcolorbox}
%\end{table}
\ntable
\end{document}
the \ntable
produces the error
! File ended while scanning use of \TX@get@body.
How can I fix it?
\newenvironment
? Maybe that can work.\newenvironment
get parameters?tcolorbox
itself. I will try to post something in some time.tabularx
package for ways to include tabularx in an environment definition. (It would be much better to use environment syntax than\btable
\ntable
environments are a core syntactic construct in latex, it is best not to hide them, although for tabularx the same restrictions apply whichever form you use.