拆分表格列行以适合默认页面宽度

拆分表格列行以适合默认页面宽度

附录 A 中有下表。我想让表格适合任何其他常规页面的宽度。如何将特定列行的长内容拆分为 2 行以适合,我还能做什么?这是我的附录表:

\documentclass{article}
    \usepackage{booktabs,makecell,tabularx}
    \renewcommand\theadfont{\small}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \usepackage{siunitx}
    \renewcommand{\thetable}{\arabic{table}} 
\begin{document}
    \section{\\Appendix: One-sample t-test 5\% results of ABCD accuracy vs. accuracy of other JKFG HIJK accuracy} \label{App:AppendixA}
    \begin{table}[H]
        \centering
        \begin{tabular}{||c c c c c ||} 
            \hline
            Dataset & No. of SKLH & ABCD Accuracy & Mean of JKFG Accuracy& T-test\\ [0.5ex] 
            \hline\hline
            Cardiotocography & 1 & 0.999 & 0.999 & - \\ 
            \hline
            Cardiotocography &  4 & 0.999 & 0.999 & Not-Rejected \\ 
            \hline
            Cardiotocography &  8 & 0.999 & 0.999 & Reject \\
            \hline
            Cardiotocography & 16 & 0.999 & 0.999 & Not-Rejected \\
            \hline
            Cardiotocography & 32 & 0.999 & 0.999 & Reject \\
            \hline
            Cardiotocography & 64 & N/A & N/A & N/A \\
            \hline 
            Wall-Following Robot Navigation & 1 & 0.999 & 0.999 & - \\
            \hline
            Wall-Following Robot Navigation &   4   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Wall-Following Robot Navigation &   8   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Wall-Following Robot Navigation &   16  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Wall-Following Robot Navigation &   32  & 0.999 & 0.999 & Reject\\
            \hline
            Wall-Following Robot Navigation &   64  & 0.999 & 0.9996 & Not-Rejected\\
            \hline
            Spambase &  1   & 0.999 & 0.999 & -\\
            \hline
            Spambase &  4   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Spambase &  8   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Spambase &  16  & 0.999 & 0.999 & Reject\\
            \hline
            Spambase &  32  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Spambase &  64  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MAGIC Gamma Telescope & 1   & 0.999 & 0.999 & -\\
            \hline
            MAGIC Gamma Telescope & 4   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MAGIC Gamma Telescope & 8   & 0.999 & 0.999 & Reject\\
            \hline
            MAGIC Gamma Telescope & 16  & 0.999 & 0.999 & Reject\\
            \hline
            MAGIC Gamma Telescope & 32  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MAGIC Gamma Telescope & 64  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Letter Recognition &    1   & 0.999 & 0.999 & -\\
            \hline
            Letter Recognition & 4  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Letter Recognition & 8  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Letter Recognition & 16 & 0.999 & 0.999 & Not-Rejected\\
            \hline
            Letter Recognition & 32 & 0.999 & 0.999 & Reject\\
            \hline
            Letter Recognition & 64 & 0.999 & 0.999 & Reject\\
            \hline
            MiniBooNE particle identification & 1   & 0.999 & 0.999 & -\\
            \hline
            MiniBooNE particle identification & 4   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MiniBooNE particle identification & 8   & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MiniBooNE particle identification & 16  & 0.999 & 0.999 & Reject\\
            \hline
            MiniBooNE particle identification & 32  & 0.999 & 0.999 & Not-Rejected\\
            \hline
            MiniBooNE particle identification & 64  & 0.999 & 0.999 & Not-Rejected\\
            [1ex]\hline 
        \end{tabular}
    \end{table} 

 \end{document}

答案1

看吧,这就是你想要得到的:

\documentclass{article}
    \usepackage{booktabs,makecell}%,tabularx
    \renewcommand\theadfont{\small}
%    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \usepackage{siunitx}
%    \renewcommand{\thetable}{\arabic{table}}

\begin{document}
    \section{Appendix: One-sample t-test 5\% results of ABCD accuracy vs. accuracy of other JKFG HIJK accuracy} \label{App:AppendixA}
    \begin{table}
        \centering
        \begin{tabular}{ c S[table-format=2.0] 
                            S[table-format=1.3] 
                            S[table-format=1.4] c }
    \toprule
\thead{Dataset} 
    &   {\thead{Number\\ of SKLH}} 
        &   {\thead{ABCD\\ Accuracy}} 
            &   {\thead{Mean of\\ JKFG Accuracy}}
                &   \thead{T-test}                  \\ 
    \midrule
Cardiotocography & 1 & 0.999 & 0.999 & -            \\
Cardiotocography &  4 & 0.999 & 0.999 & Not-Rejected \\
Cardiotocography &  8 & 0.999 & 0.999 & Reject \\
    \addlinespace
Cardiotocography & 16 & 0.999 & 0.999 & Not-Rejected \\
Cardiotocography & 32 & 0.999 & 0.999 & Reject \\
Cardiotocography & 64 & N/A & N/A & N/A \\
    \addlinespace
Wall-Following Robot Navigation & 1 & 0.999 & 0.999 & - \\
Wall-Following Robot Navigation &   4   & 0.999 & 0.999 & Not-Rejected\\
Wall-Following Robot Navigation &   8   & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
Wall-Following Robot Navigation &   16  & 0.999 & 0.999 & Not-Rejected\\
Wall-Following Robot Navigation &   32  & 0.999 & 0.999 & Reject\\
Wall-Following Robot Navigation &   64  & 0.999 & 0.9996 & Not-Rejected\\
    \addlinespace
Spambase &  1   & 0.999 & 0.999 & -\\
Spambase &  4   & 0.999 & 0.999 & Not-Rejected\\
Spambase &  8   & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
Spambase &  16  & 0.999 & 0.999 & Reject\\
Spambase &  32  & 0.999 & 0.999 & Not-Rejected\\
Spambase &  64  & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
MAGIC Gamma Telescope & 1   & 0.999 & 0.999 & -\\
MAGIC Gamma Telescope & 4   & 0.999 & 0.999 & Not-Rejected\\
MAGIC Gamma Telescope & 8   & 0.999 & 0.999 & Reject\\
    \addlinespace
MAGIC Gamma Telescope & 16  & 0.999 & 0.999 & Reject\\
MAGIC Gamma Telescope & 32  & 0.999 & 0.999 & Not-Rejected\\
MAGIC Gamma Telescope & 64  & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
Letter Recognition &    1   & 0.999 & 0.999 & -\\
Letter Recognition & 4  & 0.999 & 0.999 & Not-Rejected\\
Letter Recognition & 8  & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
Letter Recognition & 16 & 0.999 & 0.999 & Not-Rejected\\
Letter Recognition & 32 & 0.999 & 0.999 & Reject\\
Letter Recognition & 64 & 0.999 & 0.999 & Reject\\
    \addlinespace
MiniBooNE particle identification & 1   & 0.999 & 0.999 & -\\
MiniBooNE particle identification & 4   & 0.999 & 0.999 & Not-Rejected\\
MiniBooNE particle identification & 8   & 0.999 & 0.999 & Not-Rejected\\
    \addlinespace
MiniBooNE particle identification & 16  & 0.999 & 0.999 & Reject\\
MiniBooNE particle identification & 32  & 0.999 & 0.999 & Not-Rejected\\
MiniBooNE particle identification & 64  & 0.999 & 0.999 & Not-Rejected\\
    \bottomrule
    \end{tabular}
\end{table}
    \end{document}

序言中的注释行对于此表格来说并非必需,但它们并无害。表格太“高”,以至于无法与章节标题放在同一页上(实际上,这对于默认文章布局有效)。

如您所见,我将三列标题分成两行,使此表变窄。我还利用booktabs包的存在重新设计了表格外观。

表格截图:

在此处输入图片描述

相关内容