如何在Beamer中实现两个表格并排?附现有单表格代码
在Beamer中实现两个表格并排的方法
在Beamer里实现两个表格并排,有两种最常用且靠谱的方法,我给你详细说下:
方法1:使用Beamer自带的columns环境
这是最适配Beamer的方案,专门用来做页面分栏,操作简单还能保证对齐效果:
\begin{frame} \frametitle{回归结果对比} \begin{columns}[t] % [t]参数让两个表格顶部对齐 \column{0.45\textwidth} % 设置左侧栏宽度 \begin{table}[H] \centering \begin{tabular}{l | c | c | c | c | c} Model & intercept & X & Y & Adjusted $R^2$ & \\ \hline \hline Coeff & 2.229 & -0.274 & 1.221 & 38\%\\ t-value & 3.404 & -0.49 & 3.907 \\ GMM-t & 2.542 & -0.444 & 3.814\\ \end{tabular} \caption{模型A回归结果} \end{table} \column{0.45\textwidth} % 设置右侧栏宽度 \begin{table}[H] \centering \begin{tabular}{l | c | c | c | c | c} Model & intercept & X & Y & Adjusted $R^2$ & \\ \hline \hline Coeff & 1.890 & -0.152 & 1.053 & 32\%\\ % 示例数据,替换成你的内容即可 t-value & 2.981 & -0.364 & 3.210 \\ GMM-t & 2.115 & -0.312 & 3.057\\ \end{tabular} \caption{模型B回归结果} \end{table} \end{columns} \end{frame}
小说明:
[t]参数让两个表格以顶部对齐,你也可以换成[c](居中对齐)或者[b](底部对齐)- 把每个栏的宽度设为
0.45\textwidth,留0.1\textwidth的空隙,避免两个表格挤在一起 - 如果表格太宽,可在
tabular前加\small或\footnotesize缩小字体
方法2:使用minipage环境
这是LaTeX通用的分栏方案,在Beamer里同样适用:
% 注意:需要在导言区加载caption包 \usepackage{caption} \begin{frame} \frametitle{回归结果对比} \begin{minipage}[t]{0.45\textwidth} \centering \begin{tabular}{l | c | c | c | c | c} Model & intercept & X & Y & Adjusted $R^2$ & \\ \hline \hline Coeff & 2.229 & -0.274 & 1.221 & 38\%\\ t-value & 3.404 & -0.49 & 3.907 \\ GMM-t & 2.542 & -0.444 & 3.814\\ \end{tabular} \captionof{table}{模型A回归结果} % 用captionof给表格加标题 \end{minipage} \hfill % 自动填充两个minipage之间的空间 \begin{minipage}[t]{0.45\textwidth} \centering \begin{tabular}{l | c | c | c | c | c} Model & intercept & X & Y & Adjusted $R^2$ & \\ \hline \hline Coeff & 1.890 & -0.152 & 1.053 & 32\%\\ t-value & 2.981 & -0.364 & 3.210 \\ GMM-t & 2.115 & -0.312 & 3.057\\ \end{tabular} \captionof{table}{模型B回归结果} \end{minipage} \end{frame}
小说明:
- 如果不需要表格标题,可以直接去掉
\captionof命令 \hfill的作用是让两个minipage分别靠向页面左右两侧,避免中间空隙过大或过小
内容的提问来源于stack exchange,提问作者Hunger Learn
相关产品推荐
相关产品推荐

