# Resizing a table using resizebox raises an error

I have tables which are quite long because they have between 9 and 25 columns. They don't even fit on a page with a landscape layout. I tried to resize them using resizebox as suggested here but it always raises an error.

This in my LaTeX-file:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{table}[ht]
\resizebox{\linewidth}{!}{%
\centering
\settowidth\mywidth{\textbf{\MakeUppercase{TABLENAME}}}
\begin{minipage}[t]{\mywidth}
\mbox{}\par
\textbf{\MakeUppercase{TABLENAME}}
\end{minipage}
%$\begin{tabular}[t]{ccccccccc} \toprule \multicolumn{1}{c}{\textbf{column 1}} & \multicolumn{1}{c}{column 2}} & \multicolumn{1}{c}{column 3} & \multicolumn{1}{c}{column 4} & \multicolumn{1}{c}{column 5} & \multicolumn{1}{c}{column 6} & \multicolumn{1}{c}{column 7} & \multicolumn{1}{c}{\textbf{column 8}} & \multicolumn{1}{c}{\textbf{column 9}}\\ \midrule value & value & value & value & value & value & value & value & value \\ \bottomrule \end{tabular} %$

\caption{My Caption}
\label{tbl:verylongtable}
}
\end{table}
\end{document}


And the exception I get is

pdflatex> ! You can't use '\hrule' here except with leaders


When I try to put the whole table environment inside the resizebox (and not only the code inside the table environment) I get the error:

pdflatex> ! Not in outer par mode


How can I scale my table anyway? I did not found a solution which works yet. And another side question: I read that in the line

\resizebox{\columnwidth}{!}{%


The % is important. Why? I only know a percentage sign as a beginning of a comment.

\resizebox is a horizontal mode command (like \mbox) so it can take the tabular but not vertical material like \centering.

Also please test your example before posting there were undefined commands and extra } unrelated to the question asked.

\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}%grrr
\begin{document}
\newlength\mywidth%grrr
\begin{table}[ht]

\centering
\settowidth\mywidth{\textbf{\MakeUppercase{TABLENAME}}}
\begin{minipage}[t]{\mywidth}
\mbox{}\par
\textbf{\MakeUppercase{TABLENAME}}
\end{minipage}

\resizebox{\linewidth}{!}{\begin{tabular}[t]{ccccccccc}
\toprule
\multicolumn{1}{c}{\textbf{column 1}} & \multicolumn{1}{c}{column 2}
%grr}
& \multicolumn{1}{c}{column 3} & \multicolumn{1}{c}{column 4} & \multicolumn{1}{c}{column 5} & \multicolumn{1}{c}{column 6} & \multicolumn{1}{c}{column 7} & \multicolumn{1}{c}{\textbf{column 8}} & \multicolumn{1}{c}{\textbf{column 9}}\\
\midrule
value & value & value & value & value & value & value & value & value \\
\bottomrule
\end{tabular}}

\caption{My Caption}
\label{tbl:verylongtable}

\end{table}
\end{document}