我需要将下表插入到具有两列布局的文档中:
\begin{table}[]
\centering
\caption{Three possible values of the difference in the probability of course completion of students assigned to effective versus ineffective treatment arms.}
\label{my-label}
\begin{tabular}{rccc}
\multicolumn{1}{c}{\multirow{2}{*}{Mean effect size, averaging across countries}} & \multicolumn{2}{l}{\begin{tabular}[c]{@{}l@{}}Probability\\ of course completion (\%)\end{tabular}} & \multicolumn{1}{l}{\multirow{2}{*}{Difference}} \\
\multicolumn{1}{c}{} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Ineffective\\ arms\end{tabular}} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Effective\\ arms\end{tabular}} & \multicolumn{1}{l}{} \\
Small & 4.6 & 5.3 & 0.8 \\
Medium & 4.6 & 8.5 & 3.9 \\
Large & 4.6 & 13.3 & 8.7
\end{tabular}
\end{table}
当我编译 PDF 时,表格无法容纳一列。它看起来是这样的:
我怎样才能解决这个问题?
或者我也可以使用这个代码:
\begin{table}[]
\centering
\caption{Three possible values of the difference in the probability of course completion of students assigned to effective versus ineffective treatment arms.}
\label{my-label}
\begin{tabular}{rccc}
\multicolumn{1}{p{2cm}}{\multirow{2}{*}{Mean effect size, averaging across countries}} & \multicolumn{2}{l}{\begin{tabular}[c]{@{}l@{}}Probability\\ of course completion (\%)\end{tabular}} & \multicolumn{1}{l}{\multirow{2}{*}{Difference}} \\
\multicolumn{1}{c}{} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Ineffective\\ arms\end{tabular}} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}}Effective\\ arms\end{tabular}} & \multicolumn{1}{l}{} \\
Small & 4.6 & 5.3 & 0.8 \\
Medium & 4.6 & 8.5 & 3.9 \\
Large & 4.6 & 13.3 & 8.7
\end{tabular}
\end{table}
我得到了这个:
答案1
一种变体,也带有makecell
和siunitx
,以及booktabs
和caption
:
\documentclass{acm_proc_article-sp}
\usepackage{lipsum}
\usepackage{multirow, tabularx, caption, booktabs}
\usepackage{makecell}
\renewcommand\cellalign{rc}
\usepackage{siunitx}
\sisetup{table-format=1.1}
\begin{document}
\lipsum[2]%
\begin{table}[! htbp]\captionsetup{font=bf}
\centering\setlength\tabcolsep{8pt}
\caption{Three possible values of the difference in the probability of course completion of students assigned to effective versus ineffective treatment arms.}
\label{my-label}
\begin{tabularx}{\linewidth}{XSS[table-format=2.1]S}
& \multicolumn{2}{l}{\thead{Probability of \\ course completion (\%)}}
& \\
\cmidrule(lr){2-3}
\multirowcell{-4}[0.3ex]{Mean effect size,\\averaging\\ across countries}& {\thead{Ineffective\\ arms}} & {\thead{Effective\\ arms}} & {\multirowcell{-1}[-1ex]{Difference}}
\\[-1.4ex]
\midrule
Small & 4.6 & 5.3 & 0.8 \\
Medium & 4.6 & 8.5 & 3.9 \\
Large & 4.6 & 13.3 & 8.7
\end{tabularx}
\end{table}
\lipsum[3-8]
\end{document}
答案2
问题在于表格的构造。由于您没有提供 MWE,我使用了一些旧图片中的 MWE...无论如何,获得的表格宽度为 80 毫米。这应该适合一列。在您的文档中尝试以下代码,看看这是否是您想要的。
\documentclass[11pt, border=1mm,
preview]{standalone}
\usepackage{makecell}
\usepackage{siunitx}
\begin{document}
\begin{table}
\linespread{0.9}
\centering
\caption{Three possible values of the difference in the probability of course completion of students assigned to effective versus ineffective treatment arms.}
\label{my-label}
\begin{tabular}{rSSS}
\thead{Mean effect size,\\
averaging across \\countries}
& \multicolumn{2}{c}{\thead{Probability of \\
course completion\\
(\%)}}
& {\thead{Difference}} \\
& {\thead{Ineffective\\ arms}}
& {\thead{Effective\\ arms}}
& \\
\hline
Small & 4.6 & 5.3 & 0.8 \\
Medium & 4.6 & 8.5 & 3.9 \\
Large & 4.6 & 13.3 & 8.7
\end{tabular}
\end{table}
\end{document}
对于上表,我使用了两个包:makecell
,其中我使用thead
宏(用它替换multirow
)和siunitx
列样式S
,它可以更好地对齐数字。
表格通常有顶部和底部规则。我没有包括它们,因为您的示例中没有显示它们。对于它们的使用,我建议使用booktab
包。