# Error while scaling a table

I'm trying to scale this too wide table, but I'm getting an error and unable to solve this problem at all. Here is the error: "! You can't use \hrule' here except with leaders" on the caption line".

Here is a simplified file:

\documentclass[10pt, a4paper]{article}
\usepackage{graphicx}

\textwidth 16cm
\textheight 23.5cm
\evensidemargin 0cm
\oddsidemargin 0cm
\parskip0.1explus0.0exminus0.0ex

\newcommand{\EVE}{\texttt{{EVE}}}

\usepackage{url}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{cite}
\usepackage{tabu}
\usepackage{color}
\usepackage[table]{xcolor}
\usepackage{array,ragged2e}
\usepackage{caption}
\usepackage{breqn}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{algorithmic}
\newcommand{\R}{\mathbb{R}}
\newcommand{\I}[1]{\textbf{\texttt{#1}}}

\begin{document}

\section{Test}

\begin{table}
\centering
\scalebox{0.8}{
\caption{The table}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\multicolumn{1}{|c|}{\textbf{1}} & \multicolumn{1}{|c|}{\textbf{2 }} & \multicolumn{1}{|c|}{\textbf{3}} & \multicolumn{1}{|c|}{\textbf{4}} & \multicolumn{1}{|c|}{\textbf{5}} & \multicolumn{1}{|c|}{\textbf{6}} & \multicolumn{1}{|c|}{\textbf{7}} & \multicolumn{1}{|c|}{\textbf{8}}\\
\hline

1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline

\end{tabular}
}
\\[10pt]
\end{table}

\end{document}

-
\scalebox is a horizontal thing like \mbox so can not include display code such as \caption unless that is nested in a parbox or minipage. Just scale the tabular (and put % at the end of your lines {% and \end{tabular}%otherwise scalebox will do the wrong thing) –  David Carlisle Jan 28 at 16:26
also use \multicolumn{1}{c|}{\textbf{2 }} without the | on the left or you will get doubled rules, one from the right of the previous column. –  David Carlisle Jan 28 at 16:28
Another thing: Remember to make your example minimal the next time. –  Svend Tveskæg Jan 28 at 16:38

As David Carlisle has already noted in a comment, you can't resize both the caption and the tabular material via a \scalebox command. If you do need to reduce the size of the caption material by 20%, say, you could load the caption package and issue a command such as

\usepackage[font=footnotesize]{caption}


because "footnotesize" is 20% smaller than "normalsize".

The following example does not include an adjustment to the size of the caption.

\documentclass[a4paper]{article}
\usepackage{graphicx} % for \scalebox macro

\begin{document}    \begin{table}
\caption{The table}
\smallskip % get some separation between the caption and the tabular
\centering
\scalebox{0.8}{%  % 20% linear reduction of all items
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
\textbf{1} & \textbf{2} & \textbf{3} & \textbf{4} &
\textbf{5} & \textbf{6} & \textbf{7} & \textbf{8} \\
\hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline
\end{tabular}%
}
\end{table}
\end{document}
`
-