2

I have a very big (wide and long) table that want to show in only one page. I did not want to convert it to figure, or change the fonts. So I shrank the table margins (without shrinking the contents) and used some extra margins of the page as well:

\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}

Here is the output:

First page:

enter image description here

Second page:

enter image description here

Third page:

enter image description here

Now, there are two problems;

  1. The horizontal alignment of all the cells is okay.

    Also for the vertical alignment of multirow items are good.

    But the "one-row" cells are not exactly in the middle of the cells (vertically). They are close to top of the cells. I used m{2cm} instead of r after \begin{tabular}{|c|c?r|... but it changes the horizontal alignments and also does not align the items vertically.

    How can I centralize the cell contents vertically without changing the horizontal alignment, and without changing the whole table's position?

  2. I wanted to hide the page number in the second page (because of its overlap with the table), so I used \thispagestyle{empty}. But it removed the page number in the first page.

    How can I hide the page number just in the second page?

I appreciate any ideas or solutions.

  • 1
    Try using the afterpage package as explained in tex.stackexchange.com/questions/33007/… – Raaja May 20 '17 at 4:51
  • 1
    Why are you using \bigstrut? At least for your table it seams, that the output looks better if you set \arraystrech up to like 0.85 and remove all \bigstrut. Then it is still not perfect but better for the normal lines. But the multi row items then don't work correctly. – Georg May 20 '17 at 19:52
1

Edit: I have just seen an easier solution so I thought I will add it on top of my post here. You could use \setlength\extrarowheight{...pt}.



Ok this time I fixed your problem without proposing a completely new table. I added the array package and used >{\llap{\phantom{\textsuperscript{2}}}} on the columns. \llap so that the inserted space dose not widen our column or influence the positioning of the text and \phantom because we just want to add space not actual text. With \textsuperscript{2} we trick the cells into believing that there is superscript text so that LaTeX is forced to provide us more space at the top. I then further lowered the \arraystretch.
The problem of the page number is again fixed by inserting \clearpage before and after the tabular

\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}

The result looks good:

enter image description here

enter image description here



You can delete the \bigstrut commands from the above code and set \renewcommand{\arraystretch}{0.7} to get the same result but without the need to always manually call \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}

enter image description here



You could also define \thispagestyle{empty} inside the table environment. and get rid of all \clearpage or \pagebreak commands but at least in your MWE this leads to a false placement of the table. But in an actual Text where the pages are filled with text this might be the better way to do it.

2

I would propose a completely different table design with the use of booktabs and siunitx. The issue of the page numbering could be fixes by inserting \clearpage (assuming you know where you want to put the table exactly).

I know that is not exactly what you came for but maybe it is still helpful to you.

\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}

enter image description here

  • Thank you for the answer. Your solution has a nicer view, but for unity with other tables and some other reasons I'd rather using the same look (i.e., full vertical and horizontal lines). – Alisa May 20 '17 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.