在宽大的表格中垂直集中单元格内容,而不改变水平对齐方式

在宽大的表格中垂直集中单元格内容,而不改变水平对齐方式

我有一张非常大(又宽又长)的表格,只想在一页中显示。我不想将其转换为图形,也不想更改字体。所以我缩小了表格边距(不缩小内容),并且还使用了页面的一些额外边距:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{adjustbox}
\usepackage{makecell}
\newcolumntype{?}{!{\vrule width 2pt}}

\begin{document}
This is the first page. Please see the second page; 

it has a long table that we want to centralize its cell contents vertically without changing its horizontal alignments.
\renewcommand{\arraystretch}{0.45}
\begin{table}[htbp]
  \vspace*{-85pt}
  \centering
  \caption{Comparison of the results}
  \setlength\tabcolsep{2pt} %if need to shrink more, reduce to 2.2
\begin{adjustbox}{center}
\begin{tabular}{|c|c?r|r|r|r|r|r|r|r|r|r|r|}
    \hline
    Method & Project & \multicolumn{1}{c|}{\# of devs} & \multicolumn{1}{c|}{\# of bugs} & \multicolumn{1}{c|}{Top1} & \multicolumn{1}{c|}{Top5} & \multicolumn{1}{c|}{P@1} & \multicolumn{1}{c|}{r@1} & \multicolumn{1}{c|}{p@5} & \multicolumn{1}{c|}{r@5} & \multicolumn{1}{c|}{p@10} & \multicolumn{1}{c|}{r@10} & \multicolumn{1}{c|}{MRR} \bigstrut\\
    \hline \Xhline{4\arrayrulewidth}
    Method 1 and method 2 & All projects & 75-4,079 & 566-16,184 & 47    & 75    & 46.99 & 40.83 & 17.15 & 71.75 & 9.81 & 81.63 & 0.54 \bigstrut\\
    \hline \Xhline{2\arrayrulewidth}
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &     66  &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       & 11 \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{ Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{ Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{ Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{ Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \end{tabular}%
\end{adjustbox}
  \setlength\tabcolsep{6pt} %Original left and right margins.
  \label{tab:addlabel}%
  \vspace*{-85pt}
\end{table}%
\thispagestyle{empty} 
\pagebreak
This is the third page. Please see the second page. 
\end{document}

输出如下:

第一页:

在此处输入图片描述

第二页:

在此处输入图片描述

第三页:

在此处输入图片描述

现在,有两个问题;

  1. 所有单元格的水平对齐均正常。

    对于多行项目的垂直对齐也很好。

    但是“单行”单元格并不完全位于单元格的中间(垂直方向)。它们靠近单元格的顶部。我使用了afterm{2cm}而不是,但它会改变水平对齐,也不会垂直对齐项目。r\begin{tabular}{|c|c?r|...

    如何在不改变水平对齐方式并且不改变整个表格的位置的情况下垂直集中单元格内容?

  2. 我想隐藏第二页的页码(因为它与表格重叠),所以我使用了\thispagestyle{empty}。但它删除了第一页的页码。

    如何隐藏页码只是在第二页?

我感谢任何想法或解决方案。

答案1

编辑:我刚刚看到了一个更简单的解决方案,所以我想我会把它添加到我的帖子顶部。您可以使用\setlength\extrarowheight{...pt}



好的,这次我解决了您的问题,而没有提出一个全新的表格。我添加了array包并>{\llap{\phantom{\textsuperscript{2}}}}在列上使用。\llap这样插入的空间就不会加宽我们的列或影响文本的位置,\phantom因为我们只想添加空间而不是实际文本。我们\textsuperscript{2}欺骗单元格相信有上标文本,这样 LaTeX 就被迫在顶部为我们提供更多空间。然后我进一步降低了\arraystretch。通过在表格之前和之后
插入,页码问题再次得到解决\clearpage

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{adjustbox}
\usepackage{makecell}
\newcolumntype{?}{!{\vrule width 2pt}}

\usepackage{array}

\begin{document}
This is the first page. Please see the second page; 

it has a long table that we want to centralize its cell contents vertically without changing its horizontal alignments.
\renewcommand{\arraystretch}{0.13}\clearpage
\begin{table}[htbp]
  \vspace*{-85pt}
  \centering
  \caption{Comparison of the results}
%  \setlength\tabcolsep{2pt} %if need to shrink more, reduce to 2.2
\begin{adjustbox}{center}
\begin{tabular}{|c|c? *{11}{ >{\llap{\phantom{\textsuperscript{2}}}}r| }}
    \hline
    Method & Proj & \multicolumn{1}{c|}{\# of devs} & \multicolumn{1}{c|}{\# of bugs} & \multicolumn{1}{c|}{Top1} & \multicolumn{1}{c|}{Top5} & \multicolumn{1}{c|}{P@1} & \multicolumn{1}{c|}{r@1} & \multicolumn{1}{c|}{p@5} & \multicolumn{1}{c|}{r@5} & \multicolumn{1}{c|}{p@10} & \multicolumn{1}{c|}{r@10} & \multicolumn{1}{c|}{MRR} \bigstrut\\
    \hline \Xhline{4\arrayrulewidth}
    Method 1 \& 2 & All & 75-4,079 & 566-16,184 & 47    & 75    & 46.99 & 40.83 & 17.15 & 71.75 & 9.81 & 81.63 & 0.54 \bigstrut\\
    \hline \Xhline{2\arrayrulewidth}
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &     66  &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       & 11 \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \bigstrut\\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \bigstrut\\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \bigstrut\\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \bigstrut\\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \bigstrut\\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \bigstrut\\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \bigstrut\\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \bigstrut\\
    \hline
    \end{tabular}%
\end{adjustbox}
  \setlength\tabcolsep{6pt} %Original left and right margins.
  \label{tab:addlabel}%
  \vspace*{-85pt}
\end{table}%
\thispagestyle{empty} 
\clearpage
This is the third page. Please see the second page. 
\end{document}

结果看起来不错:

在此处输入图片描述

在此处输入图片描述



\bigstrut您可以从上面的代码中删除命令并设置\renewcommand{\arraystretch}{0.7}以获得相同的结果,但无需始终手动调用\bigstrut

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{adjustbox}
\usepackage{makecell}
\newcolumntype{?}{!{\vrule width 2pt}}

\usepackage{array}

\begin{document}
This is the first page. Please see the second page; 

it has a long table that we want to centralize its cell contents vertically without changing its horizontal alignments.
\renewcommand{\arraystretch}{0.7}\clearpage
\begin{table}[htbp]
  \vspace*{-85pt}
  \centering
  \caption{Comparison of the results}
%  \setlength\tabcolsep{2pt} %if need to shrink more, reduce to 2.2
\begin{adjustbox}{center}
\begin{tabular}{|c|c? *{11}{ >{\llap{\phantom{\textsuperscript{2}}}}r| }}
    \hline
    Method & Proj & \multicolumn{1}{c|}{\# of devs} & \multicolumn{1}{c|}{\# of bugs} & \multicolumn{1}{c|}{Top1} & \multicolumn{1}{c|}{Top5} & \multicolumn{1}{c|}{P@1} & \multicolumn{1}{c|}{r@1} & \multicolumn{1}{c|}{p@5} & \multicolumn{1}{c|}{r@5} & \multicolumn{1}{c|}{p@10} & \multicolumn{1}{c|}{r@10} & \multicolumn{1}{c|}{MRR} \\
    \hline \Xhline{4\arrayrulewidth}
    Method 1 \& 2 & All & 75-4,079 & 566-16,184 & 47    & 75    & 46.99 & 40.83 & 17.15 & 71.75 & 9.81 & 81.63 & 0.54 \\
    \hline \Xhline{2\arrayrulewidth}
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &     66  &  \\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       & 11 \\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \hline
    \multirow{3}[6]{*}{Method 6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
\cline{2-13}          & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \hline
    Method 3 & P & 1510  & 69,829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \hline
    \multirow{7}[14]{*}{Method 4} & Q & 3,014  & 188,139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & X & 2,144  & 177,637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
\cline{2-13}          & Y & 1,695  & 43,162 & 40    & 78    &       &       &       &   10    &       &       &  \\
\cline{2-13}          & X & 380   & 23,522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
\cline{2-13}          & Z & 374   & 17,084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
\cline{2-13}          & P   & 293   & 19,430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
\cline{2-13}          & Q  & 156   & 34,220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \hline
    \multirow{2}[4]{*}{Method 5} & P & ?     & 549,962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
\cline{2-13}          & P & ?     & 306,297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \hline
    \end{tabular}%
\end{adjustbox}
  \setlength\tabcolsep{6pt} %Original left and right margins.
  \label{tab:addlabel}%
  \vspace*{-85pt}
\end{table}%
\thispagestyle{empty} 
\clearpage
This is the third page. Please see the second page. 
\end{document}

在此处输入图片描述



您还可以\thispagestyle{empty}在表格环境中定义。并删除所有\clearpage\pagebreak命令,但至少在您的 MWE 中,这会导致表格放置错误。但在实际的文本中,页面中充满了文本,这可能是更好的方法。

答案2

我建议使用booktabs和来设计一个完全不同的表格siunitx。页码问题可以通过插入来解决\clearpage(假设您知道要将表格准确放在哪里)。

我知道这并不是您来这里的目的但也许它仍然对您有帮助。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{adjustbox}
\usepackage{makecell}


\usepackage{booktabs}
\usepackage{siunitx}


\begin{document}
This is the first page. Please see the second page; 

it has a long table that we want to centralize its cell contents vertically without changing its horizontal alignments.
\renewcommand{\arraystretch}{0.65}
\clearpage %%%
\begin{table}[p]
  \vspace*{-85pt}
  \centering
  \caption{Comparison of the results}
  %\setlength\tabcolsep{2pt} %if need to shrink more reduce to 2.2
\begin{adjustbox}{center}
\begin{tabular}{@{} l c S[table-format=4.0] S[table-format=6.0] S[table-format=2.2] S[table-format=2.2] *{7}{S[table-format=2.0]} @{}}
    \toprule
    Method & Proj. & \multicolumn{1}{c}{\# of devs} & \multicolumn{1}{c}{\# of bugs} & \multicolumn{1}{c}{Top1} & \multicolumn{1}{c}{Top5} & \multicolumn{1}{c}{P@1} & \multicolumn{1}{c}{r@1} & \multicolumn{1}{c}{p@5} & \multicolumn{1}{c}{r@5} & \multicolumn{1}{c}{p@10} & \multicolumn{1}{c}{r@10} & \multicolumn{1}{c}{MRR} \\
    \midrule
    1 and 2 & All & {75-4079} & {566-16184} & 47    & 75    & {46.99} & {40.83} & {17.15} & {71.75} & {9.81} & {81.63} & {0.54} \\
    \cmidrule{1-13} 
     3 & P & 1510  & 69829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {4} & Q & 3014  & 188139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
         & X & 2144  & 177637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
         & Y & 1695  & 43162 & 40    & 78    &       &       &       &   10    &       &       &  \\
         & X & 380   & 23522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
         & Z & 374   & 17084 & 52.7  & 80    &       &       &    24   &       &       &     66  &  \\
         & P   & 293   & 19430 & 45.7  & 88.8  &       &   33    &       &       &       &       & 11 \\
         & Q  & 156   & 34220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \cmidrule{1-13}
    {5} & P & ?     & 549962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
         & P & ?     & 306297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
         & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
         & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \cmidrule{1-13}
     3 & P & 1510  & 69829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {4} & Q & 3014  & 188139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
         & X & 2144  & 177637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
         & Y & 1695  & 43162 & 40    & 78    &       &       &       &   10    &       &       &  \\
         & X & 380   & 23522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
         & Z & 374   & 17084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
         & P   & 293   & 19430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
         & Q  & 156   & 34220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \cmidrule{1-13}
    {5} & P & ?     & 549962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
         & P & ?     & 306297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
         & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
         & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \cmidrule{1-13}
     3 & P & 1510  & 69829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {4} & Q & 3014  & 188139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
         & X & 2144  & 177637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
         & Y & 1695  & 43162 & 40    & 78    &       &       &       &   10    &       &       &  \\
         & X & 380   & 23522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
         & Z & 374   & 17084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
         & P   & 293   & 19430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
         & Q  & 156   & 34220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \cmidrule{1-13}
    {5} & P & ?     & 549962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
         & P & ?     & 306297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
         & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
         & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \cmidrule{1-13}
     3 & P & 1510  & 69829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {4} & Q & 3014  & 188139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
         & X & 2144  & 177637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
         & Y & 1695  & 43162 & 40    & 78    &       &       &       &   10    &       &       &  \\
         & X & 380   & 23522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
         & Z & 374   & 17084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
         & P   & 293   & 19430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
         & Q  & 156   & 34220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \cmidrule{1-13}
    {5} & P & ?     & 549962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
         & P & ?     & 306297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {6} & P & 58    & 100   & 14.4  & 48    &       &       &   20    &       &       &       &  \\
         & Q & 175   & 100   & 34.8  & 57.4  &       &       &       &       &       &       &  \\
         & X & 40    & 100   & 7.2   & 45.6  &       &       &       &       &   12    &       &  \\
    \cmidrule{1-13}
     3 & P & 1510  & 69829 & 37.81 & 68    &       &       &       &       &       &       &  \\
    \cmidrule{1-13}
    {4} & Q & 3014  & 188139 & 29.9  & 71.8  &       &       &       &       &       &       &  \\
         & X & 2144  & 177637 & 38.9  & 71.7  &       &       &       &       &       &       &  \\
         & Y & 1695  & 43162 & 40    & 78    &       &       &       &   10    &       &       &  \\
         & X & 380   & 23522 & 29.2  & 59.8  &       &       &       &       &       &       &  \\
         & Z & 374   & 17084 & 52.7  & 80    &       &       &    24   &       &       &       &  \\
         & P   & 293   & 19430 & 45.7  & 88.8  &       &   33    &       &       &       &       &  \\
         & Q  & 156   & 34220 & 30    & 73.2  &   47    &       &       &       &   44    &       &  \\
    \cmidrule{1-13}
    {5} & P & ?     & 549962 & 27.48 & 77.87 &       &       &       &    39   &       &       &  \\
         & P & ?     & 306297 & 32.99 & 77.43 &       &       &       &       &       &       &  \\
    \bottomrule
    \end{tabular}%
\end{adjustbox}
  \setlength\tabcolsep{6pt} %Original left and right margins.
  \label{tab:addlabel}%
  \vspace*{-85pt}
\end{table}%
\thispagestyle{empty} 
\clearpage%%%
This is the third page. Please see the second page. 
\end{document}

在此处输入图片描述

相关内容