在具有 2 列佈局的文件中插入表格?

在具有 2 列佈局的文件中插入表格?

我需要將下表插入具有 2 列佈局的文件中:

\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}

我得到這個:

壞表2

答案1

一個變體,也帶有makecelland siunitx、 and booktabsand 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,我使用了一些舊圖片中的一張......無論如何,獲得的桌子是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列 tyle S,它提供更好的數字對齊。

在此輸入影像描述

表格通常有頂部和底部規則。我沒有包含它們,因為在您的示例中沒有呈現。對於它們的使用,我建議使用booktabpackage。

相關內容