Resize a tabular object to textwidth

\resizebox should work provided you put \usepackage{graphicx}. But here is a better option with adjustbox package. With this, you can resize only if the table goes beyond \textwidth, otherwise not.

\documentclass{article}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{showframe}   %% just for demo
\begin{document}
  \begin{table}[h!]
  \centering
  \begin{adjustbox}{max width=\textwidth}
  \begin{tabular}{*{14}{|c}|}%%{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
  \hline
  One & Two &Three & Four & Five & Six & Seven & Eight & Nine & Ten & Eleven &
  Twelve & Thirteen & Fourteen\\
  \hline
  \hline
  $1.111$ & $2.222$ & $3.333$ & $4.444$ & $5.555$ & $6.666$ & $7.777$ &
  $8.888$ & $9.999$ & $0.000$ & $1.111$ & $2.222$ & $3.333$ & $4.444$\\
  \hline
\end{tabular}
\end{adjustbox}
  \caption{Test Table}
  \label{tab:label_test}
\end{table}
\end{document}

enter image description here


you have two unwanted spaces. Use

\documentclass{article}
\usepackage{graphicx}
\usepackage{showframe}   %% just for demo
\begin{document}
  \begin{table}
  \resizebox{\textwidth}{!}{%
  \begin{tabular}{*{14}{|c}|}%%{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}\hline
  One & Two &Three & Four & Five & Six & Seven & Eight & Nine & Ten & Eleven &
  Twelve & Thirteen & Fourteen\\\hline\hline
  $1.111$ & $2.222$ & $3.333$ & $4.444$ & $5.555$ & $6.666$ & $7.777$ &
  $8.888$ & $9.999$ & $0.000$ & $1.111$ & $2.222$ & $3.333$ & $4.444$\\\hline
\end{tabular}%
}
  \caption{Test Table}\label{tab:label_test}
\end{table}
\end{document}

enter image description here

Tags:

Scaling

Tables