[Tex/LaTex] How to properly fit table to page margin

longtabletablestabularx

I have a table that is define as follows:

\documentclass[a4paper]{paper}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}

\begin{table}[h]
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{|*{10}{c|}}
\hline
 \multirowcell{3}{Work} & \multirowcell{3}{Prime\\[1ex] (bits)} & \multicolumn{5}{c|}{Area} & \multicolumn{3}{c|}{Time} \\
 \cline{3-10}
& & \makecell{\# \\FFs} & \makecell{\#\\ LUTs} & \makecell{\#\\ Slices} & \makecell{\# \\ DSPs} & \makecell{\# \\ BRAMs} & \makecell{Freq.\\ (MHz)} & \makecell{Latency \\ (cc${}\times 10^6$)} & \makecell{Total time\\ (ms)} \\
\hline \hline
% Partially removed for brevity
\end{tabular}}
\caption{Comparison of hardware architectures}
\label{tab:hard}
\end{table}

\end{document}

The point is that this works fine and fits the table to my page's margin, but several people here pointed out to me that using \resizebox is not recommended and can lead to inconsistent font sizes. Therefore, I would like to hear (and see some examples) as what is a proper way to fit a table to my page's margin? Please also note that I will need to use some footnotes inside the table too.

Best Answer

Getting rid of some repetitive material in the header cells and switching to a tabular* environment (with \tabcolsep set to 0pt) enables you to typeset the material in portrait mode without resorting to the \resizebox "hammer". And, for better-spaced horizontal lines, load the booktabs package and use \toprule, \midrule, \cmidrule, and bottomrule instead of \hline and \cline. Finally, if you're at all interested in creating tables with an open or inviting "look", do get rid of all vertical bars -- they're not needed. Really.

enter image description here

\documentclass[a4paper]{paper}
\usepackage{multirow,booktabs}
\usepackage{makecell}

\begin{document}

\begin{table}[h]
\setlength\tabcolsep{0pt} % make LaTeX figure out optim. amount of intercol. space
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{10}{c} }
\toprule
 \multirowcell{3}{Work} & 
 \multirowcell{3}{Prime\\[1ex] (bits)} & 
 \multicolumn{5}{c}{Area} & 
 \multicolumn{3}{c}{Time} \\
\cmidrule{3-7} \cmidrule{8-10}
& & \makecell{\# \\FFs} & \makecell{\#\\ LUTs} & \makecell{\#\\ Slices} 
& \makecell{\# \\ DSPs} & \makecell{\# \\ BRAMs} & \makecell{Freq.\\ (MHz)} 
& \makecell{Latency \\ (cc${\times}10^6$)} & \makecell{Total\\ (ms)} \\
\midrule 
\bottomrule
% Partially removed for brevity
\end{tabular*}
\caption{Comparison of hardware architectures}
\label{tab:hard}
\end{table}

\end{document}
Related Question