我正在创建beamer
一张带有表格的幻灯片。这个表格对于正常字体大小来说太大了,所以我使用命令shrink
尝试将其缩小。
shrink
可以正常工作,但是它完全破坏了垂直居中。我的文本现在全部挤在幻灯片顶部,而不是垂直居中。您能否建议一种方法来强制将其移到幻灯片下方?
以下是该框架的代码:
\begin{frame}[shrink=35]{Correlations between Harm, Unfairness and Disgust}
\begin{center}
\begin{tabular}{lllllllll}
\multicolumn{8}{l}{\textbf{Table 3.} All possible regressions of harm, unfairness, and disgust predicting punishment} \\
\toprule
& M1 & M2 & M3 & M4 & M5 & M6 & M7 \\
\midrule
Harm & .35 (.01) & & & .20 (.15) & & .24 (.07) & .14 (.31) \\
Unfairness & & .41 (.01) & & .31 (.02) & .34 (.01) & & .28 (.04) \\
Disgust & & &.34 (.01) & & .23 (.07) & .25 (.05) & .19 (.13) \\
R^2 & .12 & .11 & .11 & .20 & .17 & .17 & .22 \\
\bottomrule
\multicolumn{8}{l}{Note: Standardized beta coefficients, with p value in parenthesis} \\
\end{tabular}
\end{center}
\end{frame}
答案1
您可以将桌子\resizebox
从graphicx
包裹中包裹起来。
\documentclass{beamer}
\usepackage{booktabs}
\usepackage{graphicx} % loaded by beamer, but included here for explicitness
\begin{document}
\begin{frame}{Correlations between Harm, Unfairness and Disgust}
\begin{center}
\resizebox{\textwidth}{!}{%
\begin{tabular}{lllllllll}
\multicolumn{8}{l}{\textbf{Table 3.} All possible regressions of harm, unfairness, and disgust predicting punishment} \\
\toprule
& M1 & M2 & M3 & M4 & M5 & M6 & M7 \\
\midrule
Harm & .35 (.01) & & & .20 (.15) & & .24 (.07) & .14 (.31) \\
Unfairness & & .41 (.01) & & .31 (.02) & .34 (.01) & & .28 (.04) \\
Disgust & & &.34 (.01) & & .23 (.07) & .25 (.05) & .19 (.13) \\
R$^2$ & .12 & .11 & .11 & .20 & .17 & .17 & .22 \\
\bottomrule
\multicolumn{8}{l}{Note: Standardized beta coefficients, with p value in parenthesis} \\
\end{tabular}}
\end{center}
\end{frame}
\end{document}
答案2
您可以使用minipage
预定义高度和可选定位参数c
来强制垂直居中:
\documentclass{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}[shrink=35]{Correlations between Harm, Unfairness and Disgust}
\begin{minipage}[c][1.3\paperheight][c]{\textwidth}
\centering
\begin{tabular}{lllllllll}
\multicolumn{8}{l}{\textbf{Table 3.} All possible regressions of harm, unfairness, and disgust predicting punishment} \\
\toprule
& M1 & M2 & M3 & M4 & M5 & M6 & M7 \\
\midrule
Harm & .35 (.01) & & & .20 (.15) & & .24 (.07) & .14 (.31) \\
Unfairness & & .41 (.01) & & .31 (.02) & .34 (.01) & & .28 (.04) \\
Disgust & & &.34 (.01) & & .23 (.07) & .25 (.05) & .19 (.13) \\
$R^{2}$ & .12 & .11 & .11 & .20 & .17 & .17 & .22 \\
\bottomrule
\multicolumn{8}{l}{Note: Standardized beta coefficients, with p value in parenthesis} \\
\end{tabular}
\end{minipage}
\end{frame}
\end{document}
答案3
与其缩小或调整整个表格环境的大小(这可能会使其实际内容(数字)几乎难以辨认),不如通过减少宏的值来有选择地减少列间空白量\tabcolsep
;下面编辑的 MWE 将其值从 6pt(默认值)减少到大约 4.5pt,同时将字体大小设置为\scriptsize
。(此外,我擅自在这里和那里应用了一些样式更改,例如,用 替换\toprule
和 ,\bottomrule
以便\midrule[\heavyrulewidth]
更好地与相邻文本留出间距,并在 $R^2$ 行之前增加一些垂直间距。最后,我还用 替换 ,tabular
以便tabular*
获得占据整个 的表格\textwidth
。)
顺便说一句,我不得不指出,框架的标题包含“相关性”一词,而表格的标题和图例指的是回归系数而不是相关系数。这种差异是否会引起观众的困惑或抵触?
\documentclass{beamer}
\usepackage{booktabs}
\setlength{\tabcolsep}{4.45pt}
\begin{document}
\scriptsize
\begin{frame}{Correlations between Harm, Unfairness and Disgust}
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}*{7}{l}@{}}
\multicolumn{8}{@{}p{\textwidth}}{\textbf{Table 3.} All possible regressions
of harm, unfairness, and disgust predicting punishment} \\
\midrule[\heavyrulewidth]
& M1 & M2 & M3 & M4 & M5 & M6 & M7 \\
\midrule
Harm & .35 (.01) & & & .20 (.15) & & .24 (.07) & .14 (.31) \\
Unfairness & & .41 (.01) & & .31 (.02) & .34 (.01) & & .28 (.04) \\
Disgust & & &.34 (.01) & & .23 (.07) & .25 (.05) & .19 (.13) \\[1.5ex]
$R^2$ & .12 & .11 & .11 & .20 & .17 & .17 & .22 \\
\midrule[\heavyrulewidth]
\multicolumn{8}{@{}l}{Note: Standardized beta coefficients,
with p values in parentheses} \\
\end{tabular*}
\end{frame}
\end{document}
答案4
检查编译时收到的警告信息。调整收缩因子以匹配警告信息中的信息,再次编译,然后就大功告成了!