我正在尝试使用 \resizebox{} 命令将大型表格放到投影仪幻灯片上,但它不起作用,我不知道原因。请帮忙:
\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}
答案1
这对我有用:
(将表格环境移出,resizebox
因为在调整大小框内有浮动环境是没有意义的……只留下里面的表格)
\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}
答案2
主要问题是您只指定了一列,而您的表实际上有六个列。
此外,缩放包含文本的内容不是一个好主意,而是选择合适的字体大小。
\usepackage{graphicx}
而\usepackage{hyperref}
对于 beamer 来说则没有必要。我建议使用
\cmidrule
而不是\cline
更好的垂直间距
\documentclass[12pt]{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}
\frametitle{Regionalwahlen bis 1982}
%\resizebox{\linewidth}{!}{
\begin{table}
\caption{Autonomous Community Election Results (1979-1982)} \label{tab:AC1979-82}
\tiny
\begin{tabular}{llllll}
\toprule
Autonomous & Political Party & \multicolumn{3}{c}{Share of the Vote (\%)} & Deputies (\%) \\ \cmidrule{3-5}
Community& & Proxy (1979) & Elections (1979-82) & Difference &\\ \midrule
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}
答案3
我想向您建议对你的桌子进行一些改进。
您正在使用\cline
而不是 ,\cmidrule
并且将 放在\toprule
应该有 的位置\midrule
。
此外,如果将标题分成多行,则表格所需的空间就更少。
我还添加了siunitx
每个正确的数字对齐。
编辑:正如 Bernard 向我建议的那样,\multirow...{\makecell{...}}
你可以使用等效的方法:
\multirowcell{nrow}[vmove][hor alignment]{contents}
其中nrow
= 文本应填充的表格行数,vmove
= 是您可以应用的(可选)垂直偏移(有时需要更好的对齐,在您的情况下我设置了尺寸-7pt
),hor alignment
= 是(可选)水平对齐(默认为c
),并且contents
= 文本。
\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{makecell}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{rotating}
\usepackage{gensymb}
\usepackage{textgreek}
\usepackage{subfig}
\graphicspath{ {charts/} }
\usepackage{varioref}
\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}}
\scriptsize
\begin{tabular}{ll*{4}{S[table-format=-1.2]}}
\toprule
\multirowcell{2}[-7pt][l]{Autonomous\\ Community} & \multirowcell{2}[-7pt][l]{Political\\ Party} & \multicolumn{3}{c}{Share of the Vote (\%)} &
{\multirowcell{2}[-7pt]{Deputies\\ (\%)}} \\
\cmidrule(lr){3-5}
& & {\makecell{Proxy\\ (1979)}} & {\makecell{Elections\\ (1979-82)}} & {Difference} &\\
\midrule
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}
这是结果,我认为它看起来比以下好得多\resizebox
: