表格对齐间距

表格对齐间距

我对下表有些疑问。UC 和 CC 之间应该有一个空格。不幸的是,它没有,因此后面列的内容也没有对齐。任何提示都很好!

\documentclass{article}      
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{@{}*{2}{l S[table-format=1.0] S[table-format=5.0] SS} @{}}
\toprule   % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} &  & {UC} & {IND} & {CC} \\
\cmidrule(r){3-5} \cmidrule(r){7-9}  % leave gap between the two rules
Normal & 1 & 1000 &  & 0.999 &  & 1000 & 1000 &  0.999  \\
  & 2 & 1100 &  & 0.826  &  & 1000 & 1000 &  0.999     \\
  & 3 & 1100 &  & 0.826  &  & 1000 & 1000 &  0.999       \\[1ex]
Student-t & 1 & 1000 & 0.010 & 1.000 &  & 1000 & 1000 &  0.999   \\
  & 2 & 1100 & 0.010 & 0.866  &  & 1000 & 1000 &  0.999       \\
  & 3 & 1000 & 0.008 & 0.818   &  & 1000 & 1000 &  0.999      \\[1ex]
GED & 1 & 1000 &  & 0.998 &  & 1000 & 1000 &  0.999   \\
  & 2 & 1100 &  & 0.812  &  & 1000 & 1000 &  0.999  \\
  & 3 & 1100 &  & 0.811 &  & 1000 & 1000 &  0.999  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案1

配固定柱规格:

\documentclass{article}
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{
  l
  S[table-format=1.0]
  S[table-format=4.0]
  S
  S
  l
  S[table-format=4.0]
  S[table-format=4.0]
  S
}
\toprule   % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} & & {UC} & {IND} & {CC} \\
\cmidrule(lr){3-5} \cmidrule(lr){7-9}  % leave gap between the two rules
Normal
  & 1 & 1000 &       & 0.999 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 &       & 0.826 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 &       & 0.826 & & 1000 & 1000 & 0.999 \\
\addlinespace
Student-t
  & 1 & 1000 & 0.010 & 1.000 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & 0.010 & 0.866 & & 1000 & 1000 & 0.999 \\
  & 3 & 1000 & 0.008 & 0.818 & & 1000 & 1000 & 0.999 \\
\addlinespace
GED
  & 1 & 1000 &       & 0.998 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 &       & 0.812 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 &       & 0.811 & & 1000 & 1000 & 0.999 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

结果

答案2

&在第一行忘记了一个。我稍微修改了表格序言,因为具有整数的列实际上不需要S列类型,至少从您向我们展示的内容来看是这样。还修改了以下内容的裁剪\cmidrules

\documentclass{article}
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3,table-number-alignment=center} % default numerical column spec
\begin{document}

\begin{table}
\sisetup{table-format=1.3}
\centering
\begin{tabular}{@{}lccSScccS@{\,}}%{@{}
\toprule % center non-numerical info (A, B, ...) by placing them in braces
 & {s} & {UC} & {IND} & {CC} & & {UC} & {IND} & {CC} \\
\cmidrule(lr){3-5} \cmidrule(l){7-9} % leave gap between the two rules
Normal & 1 & 1000 & & 0.999 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & & 0.826 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 & & 0.826 & & 1000 & 1000 & 0.999 \\[1ex]
Student-t & 1 & 1000 & 0.010 & 1.000 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & 0.010 & 0.866 & & 1000 & 1000 & 0.999 \\
  & 3 & 1000 & 0.008 & 0.818 & & 1000 & 1000 & 0.999 \\[1ex]
GED & 1 & 1000 & & 0.998 & & 1000 & 1000 & 0.999 \\
  & 2 & 1100 & & 0.812 & & 1000 & 1000 & 0.999 \\
  & 3 & 1100 & & 0.811 & & 1000 & 1000 & 0.999 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

相关内容