我正在尝试使用下面的包来创建下面的表格,但是它的格式不是很好组织,特别是数字,因为它们需要位于中心和标签中。有人可以帮忙使表格更具可调性并且看起来更专业吗?
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{booktabs,tabulary,lipsum}
\usepackage{dcolumn,tipa}
\newcolumntype{d}{D{.}{.}{6.5}}
\usepackage{siunitx}
\usepackage[usestackEOL]{stackengine}
\usepackage{multirow}
\begin{document}
\begin{table*}[ht]
\caption{Table ex.}
\label{tab1}
\centering
\renewcommand\footnoterule{\kern -1ex}
\renewcommand{\arraystretch}{1.3}
\begin{tabular*}{\linewidth}{l*{9}{d}}
\toprule \multirow{3}{*}{Subjects} &
\multicolumn{4}{c}{Numbers} &
\multicolumn{4}{c}{Numbers}\\
\cmidrule(r){2-5}\cmidrule(l){6-9} &
\multicolumn{1}{c}{XYZ} &
\multicolumn{1}{c}\addstackgap{\stackanchor{XYZ}{(Numbers)}} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{XYZ} &
\multicolumn{1}{c}\addstackgap{\stackanchor{XYZ}{(Numbers)}} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{Numbers Tree} \\\midrule
X1 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X2 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X3 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X4 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X5 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\\bottomrule
\end{tabular*}
\end{table*}
\end{document}
结果是这样的:
答案1
您应该使用S
的列siunitx
。
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{booktabs,tabulary,lipsum}
\usepackage{dcolumn,tipa}
\newcolumntype{d}{D{.}{.}{6.5}}
\usepackage{siunitx}
\usepackage[usestackEOL]{stackengine}
\usepackage{multirow}
\begin{document}
\begin{table*}[ht]
\sisetup{
table-number-alignment = center,
table-figures-integer = 1,
table-figures-decimal = 4
}
\caption{Table ex.}
\label{tab1}
\centering
\renewcommand\footnoterule{\kern -1ex}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{l*{8}{S}}
\toprule \multirow{3}{*}{Subjects} &
\multicolumn{4}{c}{Numbers} &
\multicolumn{4}{c}{Numbers}\\
\cmidrule(r){2-5}\cmidrule(l){6-9} &
\multicolumn{1}{c}{XYZ} &
\multicolumn{1}{c}\addstackgap{\stackanchor{XYZ}{(Numbers)}} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{XYZ} &
\multicolumn{1}{c}\addstackgap{\stackanchor{XYZ}{(Numbers)}} &
\multicolumn{1}{c}{Numbers Tree} &
\multicolumn{1}{c}{Numbers Tree} \\\midrule
X1 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X2 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X3 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X4 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X5 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\\bottomrule
\end{tabular}
\end{table*}
\end{document}
答案2
您的表格的主要问题是选择 来6.5
格式化 8 个数字列,但这种选择并不恰当;它应该1.4
贯穿始终。第二个问题是您使用了tabular*
环境,但 LaTeX 没有机会实现所需的整体宽度(此处:\linewidth
)。最后,只有 8 个(而不是 9 个)类型的列d
。
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{booktabs}
\usepackage{dcolumn,tipa}
\newcolumntype{d}[1]{D{.}{.}{#1}} % let the 'd' column type take an argument
%\usepackage{siunitx} % not needed for this example
\usepackage[usestackEOL]{stackengine}
\usepackage{multirow}
\newcommand\mcc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table*}[ht]
\caption{Table example}
\label{tab1}
%%\centering % redundant
%%\renewcommand\footnoterule{\kern -1ex} % What is this instruction doing here??
\renewcommand{\arraystretch}{1.3}
\setlength\tabcolsep{0pt} % make LaTeX figure out the intercolumn separation
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{8}{d{1.4}} } % '1.4', not '6.5'
\toprule
\multirow{3}{*}{Subjects} & \multicolumn{4}{c}{Numbers} & \multicolumn{4}{c}{Numbers}\\
\cmidrule{2-5} \cmidrule{6-9} &
\mcc{XYZ} & \mcc{\addstackgap{\stackanchor{XYZ}{(Numbers)}}} &
\mcc{Numbers Tree} & \mcc{Numbers Tree} &
\mcc{XYZ} & \mcc{\addstackgap{\stackanchor{XYZ}{(Numbers)}}} &
\mcc{Numbers Tree} & \mcc{Numbers Tree} \\
\midrule
X1 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X2 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X3 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X4 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
X5 & 0.5000 & 0.4888 & 0.0112 & 0.0001 & 0.8500 & 0.3540 & 0.2332 & 0.2367 \\
\bottomrule
\end{tabular*}
\end{table*}
\end{document}