[Tex/LaTex] beamer, reducing table size with resizebox does not work

beamerresize

I am trying to get a large table onto a beamer slide with the \resizebox{} command, but it is not working and I do not know why. Please help:

\documentclass[12pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel} 
\usepackage{csquotes} 
\usepackage{verbatim}
\usepackage[style=mla,backend=biber]{biblatex}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{gensymb}
\usepackage{textgreek}
\usepackage{graphicx}
\usepackage{subfig}
\graphicspath{ {charts/} }
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{csvsimple}
\usepackage{caption}

\begin{document}

\begin{frame}
\frametitle{Regionalwahlen bis 1982}
\resizebox{\linewidth}{!}{
\begin{table}
\caption{Autonomous Community Election Results (1979-1982)} \label{tab:AC1979-82}
\begin{tabular}{l}
Autonomous Community & Political Party &  \multicolumn{3}{c}{Share of the Vote (\%)} & Deputies (\%) \\  \cline{3-5}
&& Proxy (1979) & Elections (1979-82) & Difference &\\ \toprule
Andalucía&PP&4,29&17,09&12,80&15,60 \\
Andalucía&PSOE&33,58&52,71&19,13&60,55 \\
Andalucía&UCD&31,84&13,09&-18,75&13,76 \\
Cataluña&PSOE&29,79&22,58&-7,21&24,44 \\
Cataluña&UCD&12,00&10,68&-1,32&13,33 \\
Galicia&PP&14,22&30,75&16,53&36,62 \\
Galicia&PSOE&17,35&19,76&2,41&22,54 \\
Galicia&UCD&48,26&28,01&-20,25&33,80\\
Navarra&PP&0,00&16,06&16,06&18,57\\
Navarra&PSOE&21,97&19,02&-2,95&21,43\\
Navarra&UCD&33,03&26,80&6,23&28,57\\
País Vasco&PP&0,00&4,77&4,77&3,33\\
País Vasco&PSOE&19,09&14,21&-4,88&15,00\\
País Vasco&UCD&16,92&8,52&-8,40&10,00\\ \bottomrule
\end{tabular}
\end{table}
}
\end{frame}


\end{document}

Best Answer

This works for me:

(moved the table environment out of the resizebox because doesn't make sence to have a floating environment inside a resizebox... Left just the tabular inside)

\documentclass[12pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{csquotes} 
\usepackage{verbatim}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{textgreek}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{csvsimple}
\usepackage{caption}

\begin{document}

\begin{frame}
  \frametitle{Regionalwahlen bis 1982}
  \begin{table}
    \caption{Autonomous Community Election Results (1979-1982)} \label{tab:AC1979-82}
\resizebox{\textwidth}{!}{%
\begin{tabular}{llllll}
Autonomous Community & Political Party &  \multicolumn{3}{c}{Share of the Vote (\%)} & Deputies (\%) \\  \cline{3-5}
&& Proxy (1979) & Elections (1979-82) & Difference &\\ \toprule
Andalucía&PP&4,29&17,09&12,80&15,60 \\
Andalucía&PSOE&33,58&52,71&19,13&60,55 \\
Andalucía&UCD&31,84&13,09&-18,75&13,76 \\
Cataluña&PSOE&29,79&22,58&-7,21&24,44 \\
Cataluña&UCD&12,00&10,68&-1,32&13,33 \\
Galicia&PP&14,22&30,75&16,53&36,62 \\
Galicia&PSOE&17,35&19,76&2,41&22,54 \\
Galicia&UCD&48,26&28,01&-20,25&33,80\\
Navarra&PP&0,00&16,06&16,06&18,57\\
Navarra&PSOE&21,97&19,02&-2,95&21,43\\
Navarra&UCD&33,03&26,80&6,23&28,57\\
País Vasco&PP&0,00&4,77&4,77&3,33\\
País Vasco&PSOE&19,09&14,21&-4,88&15,00\\
País Vasco&UCD&16,92&8,52&-8,40&10,00\\ \bottomrule
\end{tabular}%
}
\end{table}
\end{frame}


\end{document}
Related Question