使表格适合页面

使表格适合页面
\documentclass[sigconf]{acmart}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{booktabs, makecell, multirow, tabularx}
\newcommand\mytab[1]{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}
\newcommand\mc[2]{\multicolumn{#1}{c}{#2}}
 \renewcommand{\algorithmiccomment}[1]{//#1}

\setcopyright{acmcopyright}
 \copyrightyear{2018}
\acmYear{2018}
\acmDOI{10.1145/1122445.1122456}

 \acmConference[Woodstock '18]{Woodstock '18: ACM Symposium on Neural
Gaze Detection}{June 03--05, 2018}{Woodstock, NY}
\acmBooktitle{Woodstock '18: ACM Symposium on Neural Gaze Detection,
June 03--05, 2018, Woodstock, NY}
\acmPrice{15.00}
\acmISBN{978-1-4503-9999-9/18/06}


\begin{document}


\title{An Automated Approach for Refining Coarse-Grained Requirement-to-Code 
Traces}


\author{Authors not shown due to the double-blind regulation}
\begin{table}[]
\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|c|}
\hline
\multirow{2}{*}{\textbf{1-Program}} & \multirow{2}{*} 
{\textbf{\begin{tabular}[c]{@{}c@{}}2-\\ Step\end{tabular}}} & 
\multicolumn{4}{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-18} 
 &  & \textbf{\begin{tabular}[c]{@{}c@{}}3-\\ Tp(\#)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}4-\\ Np(\#)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}5-\\ Ep(\#)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}6-\\ Total\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}7-\\ T(\%)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}8-\\ N(\%)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}9-\\ E(\%)\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}10-\\ TP\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}11-\\ TN\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}12-\\ FP\end{tabular}} & 
\textbf{\begin{tabular}[c]{@{}c@{}}13-\\ FN\end{tabular}} & 
 \textbf{\begin{tabular}[c]{@{}c@{}}14-\\ E\end{tabular}} & 
 \textbf{\begin{tabular}[c]{@{}c@{}}15-\\ T(\%)\end{tabular}} & 
 \textbf{\begin{tabular}[c]{@{}c@{}}16-\\ N(\%)\end{tabular}} & 
 \textbf{\begin{tabular}[c]{@{}c@{}}17-\\ T(\%)\end{tabular}} & 
 \textbf{\begin{tabular}[c]{@{}c@{}}18-\\ N(\%)\end{tabular}} \\ \hline
 \multirow{4}{*}{\textbf{Chess}} & \textbf{1} & 0 & 2063 & 3953 & 6016 & 0 & 
34.29 & 65.71 & 0 & 1612 & 0 & 0 & 4404 & NA & 1 & NA & 1 \\ \cline{2-18} 
& \textbf{2} & 0 & 3227 & 2789 & 6016 & 0 & 53.64 & 46.36 & 0 & 1841 & 0 & 
49 & 4126 & NA & 97.41 & 0 & 1 \\ \cline{2-18} 
& \textbf{3} & 908 & 3227 & 1881 & 6016 & 15.09 & 53.64 & 31.27 & 415 & 1841 
& 378 & 49 & 3333 & 52.33 & 97.41 & 89.44 & 82.30 \\ \cline{2-18} 
& \textbf{4} & \textbf{1464} & \textbf{3227} & \textbf{1325} & 
\textbf{6016} 
& \textbf{24.34} & \textbf{53.64} & \textbf{22.02} & \textbf{471} & 
\textbf{1841} & \textbf{438} & \textbf{49} & \textbf{3217} & \textbf{51.81} 
 & \textbf{97.41} & \textbf{90.58} & \textbf{80.79} \\ \hline
\multirow{4}{*}{\textbf{Gantt}} & \textbf{1} & 0 & 55535 & 34699 & 90234 & 0 
& 61.55 & 38.45 & 0 & 22365 & 0 & 0 & 67869 & NA & 1 & NA & 1 \\ \cline{2- 
18} 
 & \textbf{2} & 0 & 66609 & 23625 & 90234 & 0 & 73.82 & 26.18 & 0 & 22595 & 0 
& 57 & 67582 & NA & 99.75 & 0 & 1 \\ \cline{2-18} 
 & \textbf{3} & 896 & 66609 & 22729 & 90234 & 0.99 & 73.82 & 25.19 & 97 & 
22595 & 124 & 57 & 67361 & 43.89 & 99.75 & 62.99 & 99.45 \\ \cline{2-18} 
 & \textbf{4} & \textbf{1527} & \textbf{66609} & \textbf{22098} & 
 \textbf{90234} & \textbf{1.69} & \textbf{73.82} & \textbf{24.49} & 
 \textbf{144} & \textbf{22595} & \textbf{185} & \textbf{57} & \textbf{67253} 
 & \textbf{43.77} & \textbf{99.75} & \textbf{71.64} & \textbf{99.19} \\ 
\hline
\multirow{4}{*}{\textbf{iTrust}} & \textbf{1} & 0 & 17573 & 149469 & 167042 
 & 0 & 10.52 & 89.48 & 0 & 6572 & 0 & 0 & 160470 & NA & 1 & NA & 1 \\ 
 \cline{2-18} 
 & \textbf{2} & 0 & 28659 & 138383 & 167042 & 0 & 17.16 & 82.84 & 0 & 6685 & 
 0 & 9 & 160348 & NA & 99.87 & 0 & 1 \\ \cline{2-18} 
 & \textbf{3} & 290 & 28659 & 138093 & 167042 & 0.17 & 17.16 & 82.67 & 81 & 
 6685 & 27 & 9 & 160240 & 75 & 99.87 & 90 & 99.60 \\ \cline{2-18} 
 & \textbf{4} & \textbf{1035} & \textbf{28659} & \textbf{137348} & 
 \textbf{167042} & \textbf{0.62} & \textbf{17.16} & \textbf{82.22} & 
 \textbf{93} & \textbf{6685} & \textbf{28} & \textbf{9} & \textbf{160227} & 
 \textbf{76.86} & \textbf{99.87} & \textbf{91.18} & \textbf{99.58} \\ \hline
 \multirow{4}{*}{\textbf{JHotDraw}} & \textbf{1} & 0 & 116787 & 20133 & 
 136920 & 0 & 85.30 & 14.70 & 0 & 12013 & 0 & 0 & 124907 & NA & 1 & NA & 1 
 \\ 
 \cline{2-18} 
 & \textbf{2} & 0 & 126345 & 10575 & 136920 & 0 & 92.28 & 7.72 & 0 & 12077 & 
 0 & 106 & 124737 & NA & 99.13 & 0 & 1 \\ \cline{2-18} 
 & \textbf{3} & 1657 & 126345 & 8918 & 136920 & 1.21 & 92.28 & 6.51 & 92 & 
 12077 & 28 & 106 & 124617 & 76.67 & 99.13 & 46.46 & 99.77 \\ \cline{2-18} 
 & \textbf{4} & \textbf{2321} & \textbf{126345} & \textbf{8254} & 
\textbf{136920} & \textbf{1.70} & \textbf{92.28} & \textbf{6.03} & 
\textbf{133} & \textbf{12077} & \textbf{43} & \textbf{106} & \textbf{124561} 
& \textbf{75.57} & \textbf{99.13} & \textbf{55.65} & \textbf{99.65} \\ 
\hline
\end{tabular}
\end{table}
\end{document}

答案1

我建议使用 来简化代码makecell。数字(部分)与S中的列类型对齐siunitx,并且使用环境,表格可以适合页面sidewaystable。我删除了所有垂直线,用列组之间的间距替换其中一些。最后,我使用了 中的水平规则booktabs

\documentclass{article}
\usepackage[a4paper, showframe]{geometry}
\usepackage{lscape, rotating}
\usepackage{siunitx}
\usepackage{caption, multirow, booktabs, makecell}
\renewcommand{\theadfont}{\small\bfseries}

\begin{document}

\begin{sidewaystable}
\setlength{\tabcolsep}{2pt}
\setcellgapes{4pt}\makegapedcells
\sisetup{detect-weight}
\small
\caption{Precision/recall and completeness of the requirement-to-method
traces output by our approach }
\label{Results}
\begin{tabular}{@{}c >{\bfseries}cr*{3}{S[table-format=6.0]}@{\hskip1.5em}*{3}{S[table-format=2.2]}!{\hskip1.5em}r S[table-format=4.0]rr S[table-format=6.0]@{\hskip1.5em}*{2}{c}@{\hskip1.5em}*{2}{c}}
\multicolumn{2}{c}{}& \multicolumn{16}{c}{\bfseries Cumulative} \\
\cmidrule(r){3-18}\addlinespace[-2ex]
\multicolumn{2}{c}{} &
\multicolumn{4}{c}{\thead{Prediction}\qquad\null} & \multicolumn{3}{c}{\thead{Output\\ Completeness}\qquad\null} & \multicolumn{5}{c}{\thead{Precision \\ and Recall}\quad\enspace\null} & \multicolumn{2}{c}{\thead{Output\\ Precision}\quad\null} & \multicolumn{2}{c}{\thead{Output\\ Recall}} \\ %
\addlinespace[-1.5ex]\cmidrule(r{2em}){3-6}\cmidrule(r{2em}){7-9}\cmidrule(r{2em}){10-14}\cmidrule(r{1em}){15-16}\cmidrule(r){17-18}
\thead{1-\\Program} & \thead{2-\\ Step} & \thead{3-Tp\\(\#)} & {\thead{4-Np\\ (\#)}} & {\thead{5-Ep\\ (\#)}} & {\thead{6-\\ Total}} & {\thead{7-T\\ (\%)}} &{ \thead{8-N\\ (\%)}} & {\thead{9-E\\ (\%)}} & \thead{10-\\ TP} & {\thead{11-\\ TN}} & \thead{12-\\ FP} & \thead{13-\\ FN} & {\thead{14-\\ E}} & \thead{15-T\\ (\%)} & \thead{16-N\\ (\%)} & \thead{17-T\\ (\%)} & \thead{18-N\\ (\%)} \\ %
\addlinespace[-1.5ex]\midrule
\multirowthead{6}{Chess} & 1 & 0 & 2063 & 3953 & 6016 & 0 & 34.29 & 65.71 & 0 & 1612 & 0 & 0 & 4404 & NA & 1 & NA & 1 \\ %
\cmidrule(l){3-18}
& 2 & 0 & 3227 & 2789 & 6016 & 0 & 53.64 & 46.36 & 0 & 1841 & 0 & 49 & 4126 & NA & 97.41 & 0 & 1 \\ %
\cmidrule(l){3-18}
& 3 & 908 & 3227 & 1881 & 6016 & 15.09 & 53.64 & 31.27 & 415 & 1841 & 378 & 49 & 3333 & 52.33 & 97.41 & 89.44 & 82.30 \\ %
\cmidrule(l){3-18}
 & 4 & \bfseries 1464 & \bfseries 3227 & \bfseries 1325 &\bfseries 6016 & \bfseries 24.34 & \bfseries 53.64 & \bfseries 22.02 & \bfseries 471 & \bfseries 1841 & \bfseries 438 & \bfseries 49 & \bfseries 3217 & \bfseries 51.81& \bfseries 97.41 & \bfseries 90.58 & \bfseries 80.79 \\ %
 \midrule
\multirowthead{6}{Gantt} & 1 & 0 & 55535 & 34699 & 90234 & 0 & 61.55 & 38.45 & 0 & 22365 & 0 & 0 & 67869 & NA & 1 & NA & 1 \\ %
\cmidrule(l){3-18}
& 2 & 0 & 66609 & 23625 & 90234 & 0 & 73.82 & 26.18 & 0 & 22595 & 0 & 57 & 67582 & NA & 99.75 & 0 & 1 \\ %
\cmidrule(l){3-18}
& 3 & 896 & 66609 & 22729 & 90234 & 0.99 & 73.82 & 25.19 & 97 & 22595 & 124 & 57 & 67361 & 43.89 & 99.75 & 62.99 & 99.45 \\%
\cmidrule(l){3-18}
& 4 & \bfseries 1527 & \bfseries \num{66609} & \bfseries\num{22098} & \bfseries\num{90234} & \bfseries 1.69 & \bfseries 73.82 & \bfseries 24.49 & \bfseries 144 & \bfseries \num{22595} & \bfseries 185 & \bfseries 57 & \bfseries \num{67253} & \bfseries 43.77 & \bfseries 99.75 & \bfseries 71.64 & \bfseries 99.19 \\
\midrule
\multirowthead{6}{iTrust} & 1 & 0 & 17573 & 149469 & 167042 & 0 & 10.52 & 89.48 & 0 & 6572 & 0 & 0 & 160470 & NA & 1 & NA & 1 \\%
\cmidrule(l){3-18}
& 2 & 0 & 28659 & 138383 & 167042 & 0 & 17.16 & 82.84 & 0 & 6685 & 0 & 9 & 160348 & NA & 99.87 & 0 & 1 \\ %
\cmidrule(l){3-18}
 & 3 & 290 & 28659 & 138093 & 167042 & 0.17 & 17.16 & 82.67 & 81 & 6685 & 27 & 9 & 160240 & 75 & 99.87 & 90 & 99.60 \\ %
\cmidrule(l){3-18}
 & 4 & \bfseries 1035 & \bfseries \num{28659} & \bfseries \num{137348} & \bfseries \num{167042} & \bfseries 0.62 & \bfseries 17.16 & \bfseries 82.22 & \bfseries 93 & \bfseries 6685 & \bfseries 28 & \bfseries 9 & \bfseries \num{160227} & \bfseries 76.86 & \bfseries 99.87 & \bfseries 91.18 & \bfseries 99.58 \\ %
 \midrule
\multirowthead{6}{JHotDraw}& 1 & 0 & 116787 & 20133 & 136920 & 0 & 85.30 & 14.70 & 0 & 12013 & 0 & 0 & 124907 & NA & 1 & NA & 1 \\ %
\cmidrule(l){3-18}
& 2 & 0 & 126345 & 10575 & 136920 & 0 & 92.28 & 7.72 & 0 & 12077 & 0 & 106 & 124737 & NA & 99.13 & 0 & 1 \\ %
\cmidrule(lr){3-18}
& 3 & 1657 & 126345 & 8918 & 136920 & 1.21 & 92.28 & 6.51 & 92 & 12077 & 28 & 106 & 124617 & 76.67 & 99.13 & 46.46 & 99.77 \\ %
\cmidrule(lr){3-18}
& 4 & \bfseries 2321 & \bfseries \num{126345} & \bfseries 8254 &\bfseries \num{136920} & \bfseries 1.70 & \bfseries 92.28 & \bfseries 6.03 & \bfseries 133 & \bfseries \num{12077}& \bfseries 43 & \bfseries 106 & \bfseries \num{124561} & \bfseries 75.57 & \bfseries 99.13 & \bfseries 55.65 & \bfseries 99.65 \\ %
\bottomrule
\end{tabular}
\end{sidewaystable}

\end{document} 

在此处输入图片描述

相关内容