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:
Second page:
Third page:
Now, there are two problems;
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 ofr
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?
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.
afterpage
package as explained in tex.stackexchange.com/questions/33007/…\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.