
問題:表格沒有完全出現在我的投影機文件的框架中。請指導我
\documentclass[12pt,fleqn]{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}
\frametitle{A large table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{*{5}{c}}
\toprule
$x$ & $y$ & $x^2$ & $y^2$ & $xy$ \\
\midrule
43 & 29 & 1849 & 841 & 1247 \\
44 & 31 & 1936 & 961 & 1364 \\
46 & 19 & 2116 & 361 & 874 \\
40 & 18 & 1600 & 324 & 720 \\
44 & 19 & 1936 & 361 & 836 \\
42 & 27 & 1764 & 729 & 1134 \\
45 & 27 & 2025 & 729 & 1215 \\
42 & 29 & 1764 & 841 & 1218 \\
38 & 41 & 1444 & 1681 & 1558 \\
40 & 30 & 1600 & 900 & 1200 \\
42 & 26 & 1764 & 676 & 1092 \\
57 & 10 & 3249 & 100 & 570\\
\bottomrule
\end{tabular}%
}
\end{frame}
\end{document}
答案1
切勿\resizebox
與表格一起使用 - 它會導致字體大小不一致,有時甚至導致表格不可讀。
使用允許您指定整個表格寬度的環境,例如tabular*
或tabularx
。您也可以使用標準字體大小(\small
、 &c.)和 的值\tabcolsep
。
在這種情況下,我建議使用“tabular*”來編寫以下程式碼:
\documentclass[12pt,fleqn]{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}
\frametitle{A large table}
\centering\begin{tabular*}{\framewidth}{@{\extracolsep{\fill}}*{5}{c}}
\toprule
$x$ & $y$ & $x^2$ & $y^2$ & $xy$ \\
\midrule
43 & 29 & 1849 & 841 & 1247 \\
44 & 31 & 1936 & 961 & 1364 \\
46 & 19 & 2116 & 361 & 874 \\
40 & 18 & 1600 & 324 & 720 \\
44 & 19 & 1936 & 361 & 836 \\
42 & 27 & 1764 & 729 & 1134 \\
45 & 27 & 2025 & 729 & 1215 \\
42 & 29 & 1764 & 841 & 1218 \\
38 & 41 & 1444 & 1681 & 1558 \\
40 & 30 & 1600 & 900 & 1200 \\
42 & 26 & 1764 & 676 & 1092 \\
57 & 10 & 3249 & 100 & 570\\
\bottomrule
\end{tabular*}
\end{frame}
\end{document}