表格超出页边距

表格超出页边距

我在双栏式页面上有一个表格。我的表格超出了页边距。我尝试过使用制表格式,但是标题太近了。

表格超出页边距

\begin{table}[h!]
\centering
 \begin{tabularx}{\textwidth}{@{} l *{3}{C} } 
 \hline
{} & Average Accuracy & Average BER & Average Precision \\
 \hline\hline
Best accuracy of SVM   &    0.000353 &     0.0187451 &     0.021746 \\
Best accuracy of SVM 1   &    0.000439 &     0.001381 &    0.015361 \\
Best accuracy of KNN    &    0.000894 &     0.013037 &     0.000438 \\
Best accuracy of KNN 1  &    0.000817 &     0.024353 &    0.0195106 \\
Best accuracy of NN  &    0.009123 &     0.0254135 &    0.010304 \\
Best accuracy of NN 1   &     0.00911 &     0.036151 &    0.0147809 \\
\bottomrule
 \end{tabularx}\hspace*{-25pt}
 \caption{Results for the models}
 \label{acc}
\end{table}

如何修复此问题?

答案1

您提到您的文档采用两列布局。我假设您希望表格只占一列。如果这个假设正确,以下解决方案可能会让您感兴趣。它采用环境tabular*(宽度设置为\columnwidth)并组织标题材料,使其占用的空间比以前少得多。它还将数据列中的数字四舍五入为 6 位小数。

在此处输入图片描述

\documentclass[twocolumn]{article}
\usepackage{booktabs,amsmath,siunitx}
% handy shortcut macro:
\newcommand\mytab[1]{\smash[b]{\begin{tabular}[t]{@{}l@{}} #1 \end{tabular}}}

\begin{document}

\begin{table}[h!]
\setlength\tabcolsep{0pt} % let LaTeX figure out optimal column separation
\sisetup{table-format=1.6,group-digits=false,
         round-mode=places,round-precision=6}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} l *{3}{S} } 
\toprule
\mytab{Best accu-\\racy of} & \multicolumn{3}{c@{}}{Average} \\
\cmidrule(l){2-4}
& {Accuracy} & {BER} & {Precision} \\
\midrule
SVM    &    0.000353 &     0.0187451 &    0.021746  \\
SVM 1  &    0.000439 &     0.001381  &    0.015361  \\
KNN    &    0.000894 &     0.013037  &    0.000438  \\
KNN 1  &    0.000817 &     0.024353  &    0.0195106 \\
NN     &    0.009123 &     0.0254135 &    0.010304  \\
NN 1   &    0.00911  &     0.036151  &    0.0147809 \\
\bottomrule
\end{tabular*}
\caption{Results for the models}
\label{tab:acc}
\end{table}

\end{document}

答案2

表格太大。请使用星号版本table

\documentclass[twocolumn]{article}
\usepackage{array,booktabs,graphicx,caption}
\usepackage{blindtext,showframe}% only for demo

\begin{document}
\Blindtext 
    \begin{table*}[htb!]\centering
        \caption{Results for the models}\label{acc}
            \begin{tabular}{@{} l *3c } \hline
                & Average Accuracy & Average BER & Average Precision \\\hline\hline
                Best accuracy of SVM   &    0.000353 &     0.0187451 &     0.021746 \\
                Best accuracy of SVM 1   &    0.000439 &     0.001381 &    0.015361 \\
                Best accuracy of KNN    &    0.000894 &     0.013037 &     0.000438 \\
                Best accuracy of KNN 1  &    0.000817 &     0.024353 &    0.0195106 \\
                Best accuracy of NN  &    0.009123 &     0.0254135 &    0.010304 \\
                Best accuracy of NN 1   &     0.00911 &     0.036151 &    0.0147809 \\\bottomrule
        \end{tabular}
    \end{table*}
\Blindtext  
\end{document}

在此处输入图片描述

相关内容