我正在使用以下代码为我在 Overleaf 中撰写的论文创建表格。
\usepackage{array}
\usepackage{dcolumn}
\usepackage{booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}
\begin{table}
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}d{5.5}d{5.8}d{5.5}}
\toprule
\noalign{\vskip 0.2in}
& \multicolumn{2}{c}{Fisher-Zou} &
\multicolumn{1}{c}{Wilcox-Muska} \\
\multicolumn{1}{c}{GROUP} & \multicolumn{1}{c}{p-value} & \multicolumn{1}{c}{CI's} & \multicolumn{1}{c}{CI's} \\
\noalign{\vskip 0.2in}
\midrule
\noalign{\vskip 0.2in}
\multicolumn{1}{c}{females} \\
\noalign{\vskip 0.1in}
(A vs. B) & .0043 & .0083-.5788 & -.0671-.4987 \\
(A vs. C) & .0005 & .1630-.5764 & .0767-.4990 \\
(A vs. D) & .0096 & .0789-.6195 & .0062-.5262 \\
(A vs. E) & .6926 & -.2448-.1991 & -.1997-.1475 \\
\bottomrule
\end{tabular*}
\end{table}
问题在于这些值没有集中在子标题 p 值、CI 和 CI 下,而这些子标题又没有正确定位在标题 Fisher-Zou(应该包含数据列 2 和 3)和 Wilcox-Muska(最后一列数据)下。
请问有什么建议吗?
答案1
另一种选择是......用tabularx
和siunitx
代替D
列:
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{X S[table-format=1.4]
*{2}{S[table-format=-2.4]@{\quad--\quad}S[table-format=0.4]@{\qquad}}
}
\toprule
& \multicolumn{3}{c}{Fisher-Zou}
& \multicolumn{2}{c}{Wilcox-Muska} \\
\cmidrule(r){2-4}\cmidrule(l){5-6}
\multicolumn{1}{c}{GROUP}
& {p-value}
& \multicolumn{2}{c}{CI's}
& \multicolumn{2}{c}{CI's} \\
\midrule
females & \multicolumn{5}{c}{} \\
\addlinespace
(A vs. B) & .0043 & .0083 & .5788 & -.0671 & .4987 \\
(A vs. C) & .0005 & .1630 & .5764 & .0767 & .4990 \\
(A vs. D) & .0096 & .0789 & .6195 & .0062 & .5262 \\
(A vs. E) & .6926 & -.2448 & .1991 & -.1997 & .1475 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
使用D
列类型时,请注意每个单元格仅提供一个包含小数点标记的数字。另外,还要注意区分印刷符号-
(“减号”)和--
(“短划线”)。
我建议您按如下方式组织表格:
\documentclass{article}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{@{} l d{1.4} *{2}{d{2.4}@{\,--\,}d{1.4}} @{}}
\toprule
\addlinespace
Group & \multicolumn{1}{c}{$p$-value}
& \multicolumn{2}{c}{Fisher-Zou}
& \multicolumn{2}{c@{}}{Wilcox-Muska} \\
&& \multicolumn{2}{c}{CIs} & \multicolumn{2}{c@{}}{CIs} \\
\addlinespace
\midrule
\addlinespace
Females \\
\addlinespace
(A vs.\ B) & 0.0043 & 0.0083 & 0.5788 & -0.0671& 0.4987 \\
(A vs.\ C) & 0.0005 & 0.1630 & 0.5764 & 0.0767& 0.4990 \\
(A vs.\ D) & 0.0096 & 0.0789 & 0.6195 & 0.0062& 0.5262 \\
(A vs.\ E) & 0.6926 & -0.2448 & 0.1991 & -0.1997& 0.1475 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}