我的表格稍微超出了纸张右侧的两列,但我注意到表格单元格中有一些空间。有没有办法将单元格中的空间最小化,以防止表格溢出?
我希望保持表格原样,并尽量减少空间以适合论文的两栏。
\documentclass[10pt,conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{ctable}% http://ctan.org/pkg/ctable
\usepackage{color, colortbl}
\newcommand{\var}{\textit}
\newcommand{\proc}{\textbf}
\newcommand{\prop}{\texttt}
\newcommand{\plusplus}{{+}{+}}% Other options:
\newcommand*\ita[1]{\textit{#1}}
\usepackage{array, booktabs, makecell, multirow}% new
\definecolor{Gray}{gray}{0.9}
\usepackage{textcomp}
\renewcommand{\algorithmiccomment}[1]{//#1}
\begin{table*}[htb]
\centering
\caption{Precision/Recall and Completeness of the requirement-to-method
Traces Output by our approach}
\label{Results}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}1-\\ Program\end{tabular}}} & \multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}2-\\ Step\end{tabular}}} & \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative\\ Predictions\end{tabular}}} & \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative \\ Output\\ Completeness\end{tabular}}} & \multicolumn{5}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative Precision and \\ Recall\end{tabular}}} & \multicolumn{2}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative \\ Output \\ Precision\end{tabular}}} & \multicolumn{2}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative\\ Output \\ Recall\end{tabular}}} \\ \cline{3-17}
& & \textbf{\begin{tabular}[c]{@{}c@{}}3-\\ T\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}4-\\ N\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}5-\\ E\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}6-\\ T(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}7-\\ N(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}8-\\ E(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}9-\\ TP\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}10-\\ TN\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}11-\\ FP\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}12-\\ FN\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}13-\\ E\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}14-\\ T(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}15-\\ N(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}16-\\ T(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}17-\\ N(\%)\end{tabular}} \\ \hline
\multirow{4}{*}{\textbf{Chess}} & \textbf{1} & 0 & 2063 & 3953 & 0 & 34.29 & 65.71 & 0 & 1612 & 0 & 0 & 4404 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 3227 & 2789 & 0 & 53.64 & 46.36 & 0 & 1841 & 0 & 49 & 4126 & NA & 97.41 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 908 & 3227 & 1881 & 15.09 & 53.64 & 31.27 & 415 & 1841 & 378 & 49 & 3333 & 52.33 & 97.41 & 89.44 & 82.97 \\ \cline{2-17}
& \textbf{4} & \textbf{1464} & \textbf{3227} & \textbf{1325} & \textbf{24.34} & \textbf{53.64} & \textbf{22.02} & \textbf{471} & \textbf{1841} & \textbf{438} & \textbf{49} & \textbf{3217} & \textbf{51.82} & \textbf{97.41} & \textbf{90.58} & \textbf{80.78} \\ \hline
\multirow{4}{*}{\textbf{Gantt}} & \textbf{1} & 0 & 55535 & 34699 & 0 & 61.55 & 38.45 & 0 & 22365 & 0 & 0 & 67869 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 69880 & 20354 & 0 & 77.44 & 22.56 & 0 & 22707 & 0 & 94 & 67433 & NA & 99.59 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 677 & 69880 & 19677 & 0.75 & 77.44 & 21.81 & 84 & 22707 & 85 & 94 & 67264 & 49.70 & 99.59 & 47.19 & 99.63 \\ \cline{2-17}
& \textbf{4} & \textbf{1143} & \textbf{69880} & \textbf{19211} & \textbf{1.27} & \textbf{77.44} & \textbf{21.29} & \textbf{136} & \textbf{22707} & \textbf{136} & \textbf{94} & \textbf{67161} & \textbf{50.00} & \textbf{99.59} & \textbf{59.13} & \textbf{99.40} \\ \hline
\multirow{4}{*}{\textbf{iTrust}} & \textbf{1} & 0 & 17573 & 149265 & 0 & 10.53 & 89.47 & 0 & 6572 & 0 & 0 & 160266 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 28660 & 138178 & 0 & 17.18 & 82.82 & 0 & 6685 & 0 & 9 & 160144 & NA & 99.87 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 290 & 28660 & 137888 & 0.17 & 17.18 & 82.65 & 81 & 6685 & 27 & 9 & 160036 & 75.00 & 99.87 & 90.00 & 99.60 \\ \cline{2-17}
& \textbf{4} & \textbf{1074} & \textbf{28660} & \textbf{137104} & \textbf{0.64} & \textbf{17.18} & \textbf{82.18} & \textbf{93} & \textbf{6685} & \textbf{28} & \textbf{9} & \textbf{160023} & \textbf{76.86} & \textbf{99.87} & \textbf{91.18} & \textbf{99.58} \\ \hline
\multirow{4}{*}{\textbf{JHotDraw}} & \textbf{1} & 0 & 116787 & 20133 & 0 & 85.30 & 14.70 & 0 & 12013 & 0 & 0 & 124907 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 128756 & 8164 & 0 & 94.04 & 5.96 & 0 & 12134 & 0 & 208 & 124578 & NA & 98.31 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 1279 & 128756 & 6885 & 0.93 & 94.04 & 5.03 & 63 & 12134 & 20 & 208 & 124495 & 75.90 & 98.31 & 23.25 & 99.84 \\ \cline{2-17}
& \textbf{4} & \textbf{2000} & \textbf{128756} & \textbf{6164} & \textbf{1.46} & \textbf{94.04} & \textbf{4.50} & \textbf{95} & \textbf{12134} & \textbf{32} & \textbf{208} & \textbf{124451} & \textbf{74.80} & \textbf{98.31} & \textbf{31.35} & \textbf{99.74} \\ \hline
% \rowcolor{lightgray}
\textbf{Average} & \textbf{4} & \textbf{1420} & \textbf{57631} & \textbf{40951} & \textbf{6.93} & \textbf{60.57} & \textbf{32.50} & \textbf{199} & \textbf{10842} & \textbf{159} & \textbf{90} & \textbf{88713} & \textbf{63.37} & \textbf{98.79} & \textbf{68.06} & \textbf{94.88} \\ \hline
\end{tabular}
\end{table*}
\end{document}
答案1
使用\resizebox{\textwidth}{...
\documentclass[10pt,conference,table]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{lipsum}
\usepackage{ctable}% http://ctan.org/pkg/ctable
\newcommand{\var}{\textit}
\newcommand{\proc}{\textbf}
\newcommand{\prop}{\texttt}
\newcommand{\plusplus}{{+}{+}}% Other options:
\newcommand*\ita[1]{\textit{#1}}
\usepackage{array, booktabs, makecell, multirow}% new
\definecolor{Gray}{gray}{0.9}
\usepackage{textcomp}
\renewcommand{\algorithmiccomment}[1]{//#1}
\usepackage{blindtext}
\begin{document}
\blinddocument
\begin{table*}[htb]
\caption{Precision/Recall and Completeness of the requirement-to-method Traces Output
by our approach}
\label{Results}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}1-\\ Program\end{tabular}}}
& \multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}2-\\ Step\end{tabular}}}
& \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative\\
Predictions\end{tabular}}} &
\multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative \\ Output\\
Completeness\end{tabular}}} &
\multicolumn{5}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative Precision
and \\ Recall\end{tabular}}} &
\multicolumn{2}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative \\ Output \\
Precision\end{tabular}}} &
\multicolumn{2}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Cumulative\\ Output \\
Recall\end{tabular}}} \\ \cline{3-17}
& & \textbf{\begin{tabular}[c]{@{}c@{}}3-\\
T\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}4-\\
N\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}5-\\
E\textsubscript{p}(\#)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}6-\\
T(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}7-\\
N(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}8-\\
E(\%)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}9-\\ TP\end{tabular}}
& \textbf{\begin{tabular}[c]{@{}c@{}}10-\\ TN\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}11-\\ FP\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}12-\\ FN\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}13-\\ E\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}14-\\ T(\%)\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}15-\\ N(\%)\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}16-\\ T(\%)\end{tabular}} &
\textbf{\begin{tabular}[c]{@{}c@{}}17-\\ N(\%)\end{tabular}} \\ \hline
\multirow{4}{*}{\textbf{Chess}} & \textbf{1} & 0 & 2063 & 3953 & 0 & 34.29 &
65.71 & 0 & 1612 & 0 & 0 & 4404 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 3227 & 2789 & 0 & 53.64 & 46.36 & 0 & 1841 & 0 & 49 & 4126
& NA & 97.41 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 908 & 3227 & 1881 & 15.09 & 53.64 & 31.27 & 415 & 1841 & 378 &
49 & 3333 & 52.33 & 97.41 & 89.44 & 82.97 \\ \cline{2-17}
& \textbf{4} & \textbf{1464} & \textbf{3227} & \textbf{1325} & \textbf{24.34}
& \textbf{53.64} & \textbf{22.02} & \textbf{471} & \textbf{1841} &
\textbf{438} & \textbf{49} & \textbf{3217} & \textbf{51.82} & \textbf{97.41} &
\textbf{90.58} & \textbf{80.78} \\ \hline
\multirow{4}{*}{\textbf{Gantt}} & \textbf{1} & 0 & 55535 & 34699 & 0 & 61.55 &
38.45 & 0 & 22365 & 0 & 0 & 67869 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 69880 & 20354 & 0 & 77.44 & 22.56 & 0 & 22707 & 0 & 94 &
67433 & NA & 99.59 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 677 & 69880 & 19677 & 0.75 & 77.44 & 21.81 & 84 & 22707 & 85 &
94 & 67264 & 49.70 & 99.59 & 47.19 & 99.63 \\ \cline{2-17}
& \textbf{4} & \textbf{1143} & \textbf{69880} & \textbf{19211} & \textbf{1.27}
& \textbf{77.44} & \textbf{21.29} & \textbf{136} & \textbf{22707} &
\textbf{136} & \textbf{94} & \textbf{67161} & \textbf{50.00} & \textbf{99.59}
& \textbf{59.13} & \textbf{99.40} \\ \hline
\multirow{4}{*}{\textbf{iTrust}} & \textbf{1} & 0 & 17573 & 149265 & 0 & 10.53
& 89.47 & 0 & 6572 & 0 & 0 & 160266 & NA & 100 & NA & 100 \\ \cline{2-17}
& \textbf{2} & 0 & 28660 & 138178 & 0 & 17.18 & 82.82 & 0 & 6685 & 0 & 9 &
160144 & NA & 99.87 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 290 & 28660 & 137888 & 0.17 & 17.18 & 82.65 & 81 & 6685 & 27 &
9 & 160036 & 75.00 & 99.87 & 90.00 & 99.60 \\ \cline{2-17}
& \textbf{4} & \textbf{1074} & \textbf{28660} & \textbf{137104} &
\textbf{0.64} & \textbf{17.18} & \textbf{82.18} & \textbf{93} & \textbf{6685}
& \textbf{28} & \textbf{9} & \textbf{160023} & \textbf{76.86} & \textbf{99.87}
& \textbf{91.18} & \textbf{99.58} \\ \hline
\multirow{4}{*}{\textbf{JHotDraw}} & \textbf{1} & 0 & 116787 & 20133 & 0 &
85.30 & 14.70 & 0 & 12013 & 0 & 0 & 124907 & NA & 100 & NA & 100 \\
\cline{2-17}
& \textbf{2} & 0 & 128756 & 8164 & 0 & 94.04 & 5.96 & 0 & 12134 & 0 & 208 &
124578 & NA & 98.31 & 0 & 100 \\ \cline{2-17}
& \textbf{3} & 1279 & 128756 & 6885 & 0.93 & 94.04 & 5.03 & 63 & 12134 & 20 &
208 & 124495 & 75.90 & 98.31 & 23.25 & 99.84 \\ \cline{2-17}
& \textbf{4} & \textbf{2000} & \textbf{128756} & \textbf{6164} & \textbf{1.46}
& \textbf{94.04} & \textbf{4.50} & \textbf{95} & \textbf{12134} & \textbf{32}
& \textbf{208} & \textbf{124451} & \textbf{74.80} & \textbf{98.31} &
\textbf{31.35} & \textbf{99.74} \\ \hline
% \rowcolor{lightgray}
\textbf{Average} & \textbf{4} & \textbf{1420} & \textbf{57631} &
\textbf{40951} & \textbf{6.93} & \textbf{60.57} & \textbf{32.50} &
\textbf{199} & \textbf{10842} & \textbf{159} & \textbf{90} & \textbf{88713} &
\textbf{63.37} & \textbf{98.79} & \textbf{68.06} & \textbf{94.88} \\
\hline
\end{tabular}%
}
\end{table*}
\blinddocument
\end{document}
答案2
我的主要建议是从 a 环境切换tabular
到 atabular*
环境,并将其宽度设置为\textwidth
。还请删除 18 条垂直规则:它们确实占用了相当多的空间:而且,它们不是必需的。我还会删除大多数水平规则。
另外,不要过度使用大胆的。花时间提供清晰的结构是让表格材料更容易理解的更好方法。如下面的屏幕截图所示,我认为没有必要使用大胆的完全没有。但是,请考虑将每列中的数字与各自的小数点对齐;以下示例中将借助包siunitx
及其S
列类型完成此操作。
\documentclass[10pt,conference]{IEEEtran}
\IEEEoverridecommandlockouts
%\usepackage[table]{xcolor}
%
%\usepackage{cite}
%\usepackage{amsmath,amssymb}
%\usepackage{algorithmic,algorithm}
%\usepackage{graphicx,changepage}
%\newcommand{\var}{\textit}
%\newcommand{\proc}{\textbf}
%\newcommand{\prop}{\texttt}
%\newcommand{\plusplus}{{+}{+}}% Other options:
%\newcommand*\ita[1]{\textit{#1}}
%\usepackage{array, booktabs, makecell, multirow}% new
%\definecolor{Gray}{gray}{0.9}
%\usepackage{textcomp}
%\renewcommand{\algorithmiccomment}[1]{//#1}
\usepackage{booktabs}
\newcommand\mytab[1]{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}
\newcommand\mc[2]{\multicolumn{#1}{c}{#2}}
\usepackage{array,siunitx}
\sisetup{group-digits=false}
\newcolumntype{T}[1]{S[table-format=#1]}
\begin{document}
\begin{table*}[htb]
%%\centering % redundant
\caption{Precision/recall and completeness of the requirement-to-method traces output by our approach}
\label{Results}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
lc
T{4.0} *{2}{T{6.0}}
*{3}{T{2.2}}
T{3.0}T{5.0}*{2}{T{3.0}}T{6.0}
*{4}{T{2.2}}}
\toprule
1- & 2- & {3-} & {4-} & {5-} & {6-} & {7-} & {8-} & {9-} & {10-} &
{11-} & {12-} & {13-} & {14-} & {15-} & {16-} & {17-} \\
\addlinespace
Program & Step
& \mc{3}{\mytab{Cumulative \\ Predictions}}
& \mc{3}{\mytab{Cumulative \\ Output\\ Completeness}}
& \mc{5}{\mytab{Cumulative \\ Precision \\ and Recall}}
& \mc{2}{\mytab{Cumulative \\ Output \\ Precision}}
& \mc{2}{\mytab{Cumulative \\ Output \\ Recall}} \\
\cmidrule{3-5} \cmidrule{6-8} \cmidrule{9-13}
\cmidrule{14-15} \cmidrule{16-17}
&
& {T\textsubscript{p} (\#)} & {N\textsubscript{p} (\#)} & {E\textsubscript{p} (\#)}
& {T (\%)} & {N (\%)} & {E (\%)}
& {TP} & {TN} & {FP} & {FN} & {E}
& {T (\%)} & {N (\%)}
& {T (\%)} & {N (\%)} \\
\midrule
Chess & 1 & 0 & 2063 & 3953 & 0 & 34.29 & 65.71 & 0 & 1612 & 0 & 0 & 4404 & {NA} & 100 & {NA} & 100 \\
& 2 & 0 & 3227 & 2789 & 0 & 53.64 & 46.36 & 0 & 1841 & 0 & 49 & 4126 & {NA} & 97.41 & 0 & 100 \\
& 3 & 908 & 3227 & 1881 & 15.09 & 53.64 & 31.27 & 415 & 1841 & 378 & 49 & 3333 & 52.33 & 97.41 & 89.44 & 82.97 \\
& 4 & 1464 & 3227 & 1325 & 24.34 & 53.64 & 22.02 & 471 & 1841m& 438 & 49 & 3217 & 51.82 & 97.41 & 90.58 & 80.78 \\
\addlinespace
Gantt & 1 & 0 & 55535 & 34699 & 0 & 61.55 & 38.45 & 0 & 22365 & 0 & 0 & 67869 & {NA} & 100 & {NA} & 100 \\
& 2 & 0 & 69880 & 20354 & 0 & 77.44 & 22.56 & 0 & 22707 & 0 & 94 & 67433 & {NA} & 99.59 & 0 & 100 \\
& 3 & 677 & 69880 & 19677 & 0.75 & 77.44 & 21.81 & 84 & 22707 & 85 & 94 & 67264 & 49.70 & 99.59 & 47.19 & 99.63 \\
& 4 & 1143 & 69880 & 19211 & 1.27 & 77.44 & 21.29 & 136 & 22707 & 136 & 94 & 67161 & 50.00 & 99.59 & 59.13 & 99.40 \\
\addlinespace
iTrust & 1 & 0 & 17573 & 149265 & 0 & 10.53 & 89.47 & 0 & 6572 & 0 & 0 & 160266 & {NA} & 100 & {NA} & 100 \\
& 2 & 0 & 28660 & 138178 & 0 & 17.18 & 82.82 & 0 & 6685 & 0 & 9 & 160144 & {NA} & 99.87 & 0 & 100 \\
& 3 & 290 & 28660 & 137888 & 0.17 & 17.18 & 82.65 & 81 & 6685 & 27 & 9 & 160036 & 75.00 & 99.87 & 90.00 & 99.60 \\
& 4 & 1074 & 28660 & 137104 & 0.64 & 17.18 & 82.18 & 93 & 6685 & 28 & 9 & 160023 & 76.86 & 99.87 & 91.18 & 99.58 \\
\addlinespace
JHotDraw & 1 & 0 & 116787 & 20133 & 0 & 85.30 & 14.70 & 0 & 12013 & 0 & 0 & 124907 & {NA} & 100 & {NA} & 100 \\
& 2 & 0 & 128756 & 8164 & 0 & 94.04 & 5.96 & 0 & 12134 & 0 & 208 & 124578 & {NA} & 98.31 & 0 & 100 \\
& 3 & 1279 & 128756 & 6885 & 0.93 & 94.04 & 5.03 & 63 & 12134 & 20 & 208 & 124495 & 75.90 & 98.31 & 23.25 & 99.84 \\
& 4 & 2000 & 128756 & 6164 & 1.46 & 94.04 & 4.50 & 95 & 12134 & 32 & 208 & 124451 & 74.80 & 98.31 & 31.35 & 99.74 \\
\addlinespace
Average & 4 & 1420 & 57631 & 40951 & 6.93 & 60.57 & 32.50 & 199 & 10842 & 159 & 90 & 88713 & 63.37 & 98.79 & 68.06 & 94.88 \\
\bottomrule
\end{tabular*}
\end{table*}
\end{document}