如何生成标题而不是说明文字?

如何生成标题而不是说明文字?

在以下示例中,我想生成Table 3.1: AAA标题而不是纯标题AAA。为了进一步说明,我不希望将标题放在表格上方或下方,而应该用标题文本代替标题。有什么想法可以实现吗?

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fancy table
% http://tex.stackexchange.com/questions/112343/beautiful-table-samples
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}
\usepackage{multirow}

\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\newcolumntype{Z}{>{\centering\arraybackslash}X}

\tcbset{tab2/.style={enhanced,fonttitle=\bfseries,fontupper=\normalsize\sffamily,
        colback=yellow!10!white,colframe=red!50!black,colbacktitle=Salmon!40!white,
        coltitle=black,center title}}


\begin{document}

\begin{tcolorbox}[tab2,tabularx={Z || Z | Z | Z},title=AAA,width=0.7\textwidth]
    BBB & BBB & BBB & BBB \\ \hline\hline
    \multirow{3}{*}{XXX} & AAA & AAA & AAA \\ \cline{2-4}
    &  & AAA & AAA \\ \cline{2-4}
    &  & AAA & AAA
\end{tcolorbox}

\end{document}

在此处输入图片描述

答案1

这是你想要的吗?

\documentclass[12pt]{article}
\usepackage[table, dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{array, caption, chngcntr, etoolbox}
\AtBeginEnvironment{tcolorbox}{
\captionsetup{font={sf, bf}}}

\counterwithin{table}{section}
\tcbuselibrary{skins}
\usepackage{multirow}

\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\newcolumntype{Z}{>{\centering\arraybackslash}X}%
\tcbset{tab2/.style={enhanced,fonttitle=\bfseries,fontupper=\normalsize\sffamily,
        colback=yellow!10!white,colframe=red!50!black,colbacktitle=Salmon!40!white,
        coltitle=black,center title}}

\begin{document}

\setcounter{section}{3}

\begin{tcolorbox}[tab2, tabularx={Z || Z | Z | Z}, before title =\vspace*{-2pt}, after title=\vspace*{-13pt}, title=\captionof{table}{AAA},width=0.7\textwidth]
    BBB & BBB & BBB & BBB \\ \hline\hline
    \multirow{3}{*}{XXX} & AAA & AAA & AAA \\ \cline{2-4}
    & & AAA & AAA \\ \cline{2-4}
    & & AAA & AAA
\end{tcolorbox}

\end{document} 

在此处输入图片描述

相关内容