标题没有跨越整个表格的宽度

标题没有跨越整个表格的宽度

这是我的表格的乳胶代码。标题没有跨越整个表格的宽度。有人能帮我修复它吗?

\begin{table}[!htp]
\centering
\caption{xxx}
\scriptsize
\begin{tabular}{cccccccccccc}
\toprule[1.7pt]
& & &\multicolumn{4}{c}{Cccccccccc Ccccccccc} &\multicolumn{4}{c}{Cccccccccc Ccccccccc} \\
\cmidrule(lr){4-7} \cmidrule(lr){8-11} 
& &A &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} \\
\cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} \cmidrule(lr){10-11}
& &Ssssssss size &N = 1000&N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 \\
\toprule
\multirow{2}{*}{XXX} & &a &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} \\
& &a &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} \\
\toprule
\multirow{10}{*}{YYY} &\multirow{2}{*}{aaaa} &aaaa &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\toprule
\multirow{10}{*}{ZZZ} &\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(lr){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\bottomrule[1.7pt]
\end{tabular}
\caption*{\textit{\scriptsize aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}}
\end{table}

在此处输入图片描述

答案1

您的表格的主要问题不是标题相对于内容未居中tabular。相反,主要问题是内容tabular比 宽得多\textwidth

我建议您以横向模式排版表格。实现此目的的一种方法是使用环境sidewaystable(由旋转您可以使用包来代替table环境。

在此处输入图片描述

\documentclass{article}
\usepackage{multirow,booktabs,rotating}

% Cf. Marcel Krüger's answer at https://tex.stackexchange.com/a/694046/5001 
\usepackage{floatpag,pdflscape}
\makeatletter
\newcommand{\rotateview}{\global\@namedef{\number\@currbox @float}{\PLS@AddRotate{90}%
  \AddToHookNext{shipout/after}{\PLS@RemoveRotate}}}
\makeatother

\begin{document}

\begin{sidewaystable}
\rotateview

\centering
\caption{xxx}

\scriptsize % you should also try '\footnotesize' and '\small'
\medskip
\begin{tabular}{@{} *{11}{c} @{}} % table has 11 columns, not 12
\toprule% [1.7pt] % 1.7pt -- really?
& & &\multicolumn{4}{c}{Cccccccccc Ccccccccc} 
    &\multicolumn{4}{c@{}}{Cccccccccc Ccccccccc} \\
\cmidrule(lr){4-7} \cmidrule(l){8-11} 
& &A &\multicolumn{2}{c}{$N = 1000$} &\multicolumn{2}{c}{$N = 1000$} 
     &\multicolumn{2}{c}{$N = 1000$} &\multicolumn{2}{c@{}}{$N = 1000$} \\
\cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} \cmidrule(l){10-11}
& &Ssssssss size 
     &$N = 1000$ &$N = 1000$ &$N = 1000$ &$N = 1000$ 
     &$N = 1000$ &$N = 1000$ &$N = 1000$ &$N = 1000$ \\
     
\midrule %% \toprule

\multirow{2}{*}{XXX} & &a &
  \multicolumn{2}{c}{0.0000} & \multicolumn{2}{c}{0.0000} &
  \multicolumn{2}{c}{0.0000} & \multicolumn{2}{c@{}}{0.0000} \\
& &a &
  \multicolumn{2}{c}{0.0000} & \multicolumn{2}{c}{0.0000} &
  \multicolumn{2}{c}{0.0000} & \multicolumn{2}{c@{}}{0.0000} \\
  
\midrule %%\toprule
\multirow{10}{*}{YYY} % I'd run '\multirow{11}{*}{YYY}'
&\multirow{2}{*}{aaaa} &aaaa &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
%\cmidrule(l){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\

\midrule %% \toprule
\multirow{10}{*}{ZZZ} % I'd run '\multirow{11}{*}{ZZZ}'
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\cmidrule(l){2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
\bottomrule% [1.7pt] % 1.7pt -- really?

\end{tabular}

\end{sidewaystable}
\end{document}

答案2

  • 您没有提供有关文档页面布局的任何信息
  • 在这种情况下,当您使用a4paper并有25mm边距时,以下 MWE 可以解决您的问题:
\documentclass{article}
\usepackage[margin=25mm]{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{array, booktabs, multirow}
\usepackage{seqsplit}   % <---


\begin{document}
\begin{table}[!htp]
\centering
\caption{xxx}
\small
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{11}{c} @{}}
    \toprule
& & &\multicolumn{4}{c}{Cccccccccc Ccccccccc} &\multicolumn{4}{c}{Cccccccccc Ccccccccc} \\
    \cmidrule{4-7} \cmidrule{8-11}
& &A &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} &\multicolumn{2}{c}{N = 1000} \\
\cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} \cmidrule{10-11}
& & Ssssssss size &N = 1000&N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 &N = 1000 \\
    \midrule[0.4pt]
\multirow{2}{*}{XXX} & &a &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} \\
& &a &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} &\multicolumn{2}{c}{0.0000} \\
    \midrule[0.4pt]
\multirow{10}{*}{YYY} &\multirow{2}{*}{aaaa} &aaaa &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \midrule[0.4pt]
\multirow{10}{*}{ZZZ} &\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{4}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \cmidrule{2-11}
&\multirow{2}{*}{a} &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
& &a &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 &0.0000 \\
    \bottomrule
\end{tabular*}
\caption*{\textit{\seqsplit{ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}}}
\end{table}
\end{document}

在此处输入图片描述

相关内容