使用resizebox时如何控制标题和表格之间的距离?

使用resizebox时如何控制标题和表格之间的距离?

我正在使用 Beamer,我的幻灯片将包含许多表格。目前我有以下内容:

\documentclass[aspectratio=169, xcolor=dvipsnames]{beamer}
\author[]{bla bla bla}
\title{bla bla bla}
\usetheme{Boadilla}


\setbeamertemplate{caption}[numbered]
\usepackage{caption}
\captionsetup{skip=0pt,belowskip=-5pt}
\usepackage{booktabs}

% ---- Begin document ----
\begin{document}
\maketitle

\begin{frame}
\begin{table}

\caption{CAPM with local returns}
\centering
\resizebox{\linewidth}{!}{
\begin{tabular}[t]{lcccccccccccc}
\toprule
  & BusEquip & Chemicals & Durables & Energy & Finance & Health & Manufacturing & NonDurables & Other & Retail & Telecom & Utilities\\
\midrule
SPY Window & 1.05*** & 1.51*** & 0.38 & 2.25*** & 0.83 & 1.74*** & 1.21*** & 1.49*** & 1.53*** & 1.38*** & 0.93* & 2.11***\\
 & (0.40) & (0.34) & (0.50) & (0.55) & (0.61) & (0.38) & (0.32) & (0.36) & (0.33) & (0.32) & (0.48) & (0.47)\\
Surprise & 0.31 & 0.17 & 0.18 & 0.46 & 0.37 & 0.30* & 0.14 & 0.31* & 0.28 & 0.14 & 0.25 & 0.39*\\
 & (0.20) & (0.20) & (0.25) & (0.30) & (0.24) & (0.17) & (0.21) & (0.17) & (0.19) & (0.17) & (0.18) & (0.21)\\
Interaction & −0.37 & −0.96* & 0.56 & −1.55** & −0.34 & −1.29** & −0.35 & −0.97** & −0.87 & −0.75 & −0.56 & −1.48**\\
 & (0.62) & (0.54) & (0.83) & (0.64) & (1.02) & (0.54) & (0.66) & (0.48) & (0.62) & (0.62) & (0.66) & (0.66)\\
R2 & 0.077 & 0.088 & 0.055 & 0.092 & 0.027 & 0.120 & 0.087 & 0.123 & 0.085 & 0.088 & 0.046 & 0.133\\
R2 Adj. & 0.050 & 0.062 & 0.028 & 0.066 & −0.001 & 0.095 & 0.061 & 0.098 & 0.059 & 0.061 & 0.019 & 0.108\\
\bottomrule
\multicolumn{13}{l}{\rule{0pt}{1em}* p  0.1, ** p < 0.05, *** p < 0.01}\\
\end{tabular}}
\end{table}
\end{frame}

\begin{frame}
\begin{table}

\caption{CAPM with daily SPY returns}
\centering
\resizebox{\linewidth}{!}{
\begin{tabular}[t]{lcccccccccccc}
\toprule
  & BusEquip & Chemicals & Durables & Energy & Finance & Health & Manufacturing & NonDurables & Other & Retail & Telecom & Utilities\\
\midrule
SPY Daily & 0.64** & 0.83*** & 0.71*** & 1.03*** & 0.80*** & 0.84*** & 0.79*** & 0.66*** & 0.87*** & 0.74*** & 0.57** & 0.87***\\
 & (0.25) & (0.21) & (0.20) & (0.31) & (0.22) & (0.23) & (0.23) & (0.21) & (0.19) & (0.17) & (0.22) & (0.29)\\
Surprise & 0.22 & 0.04 & 0.16 & 0.24 & 0.30** & 0.14 & 0.03 & 0.16 & 0.15 & 0.01 & 0.17 & 0.19\\
 & (0.15) & (0.13) & (0.16) & (0.22) & (0.14) & (0.11) & (0.12) & (0.12) & (0.11) & (0.11) & (0.12) & (0.15)\\
SPY daily:Surprise & 0.39 & 0.21 & 0.82*** & 0.27 & 0.80*** & −0.02 & 0.51** & 0.16 & 0.38* & 0.33* & 0.35 & 0.07\\
 & (0.26) & (0.22) & (0.23) & (0.28) & (0.28) & (0.24) & (0.24) & (0.22) & (0.22) & (0.18) & (0.24) & (0.30)\\
R2 & 0.598 & 0.702 & 0.723 & 0.559 & 0.711 & 0.608 & 0.768 & 0.638 & 0.784 & 0.701 & 0.596 & 0.521\\
R2 Adj. & 0.586 & 0.694 & 0.715 & 0.546 & 0.703 & 0.597 & 0.761 & 0.627 & 0.778 & 0.692 & 0.585 & 0.507\\
\bottomrule
\multicolumn{13}{l}{\rule{0pt}{1em}* p < 0.1, ** p < 0.05, *** p < 0.01}\\
\end{tabular}}
\end{table}

\end{frame}

\begin{frame}
\begin{table}

\caption{Industry Regressions: BusEquip}
\centering
\fontsize{9}{11}\selectfont
\begin{tabular}[t]{lccccccccc}
\toprule
  & BK & NS & BK + NS & FFR & FG & LSAP & JME & Only MP & All\\
\midrule
SPY Window & 0.73 & 0.53 & 0.55 & 0.82* & 0.53 & 0.67 & 0.58 &  & 0.71\\
 & (0.45) & (0.58) & (0.57) & (0.42) & (0.50) & (0.42) & (0.55) &  & (0.47)\\
BK & 0.04 &  & 0.12 &  &  &  &  & −0.47 & −0.66\\
 & (0.22) &  & (0.22) &  &  &  &  & (0.51) & (0.50)\\
NS &  & −0.13 & −0.20 &  &  &  &  & 0.05 & 0.07\\
 &  & (0.19) & (0.21) &  &  &  &  & (0.48) & (0.44)\\
FFR &  &  &  & 0.13 &  &  & 0.10 & 0.43 & 0.71\\
 &  &  &  & (0.23) &  &  & (0.23) & (0.71) & (0.70)\\
FG &  &  &  &  & −0.22 &  & −0.22 & −0.32 & −0.22\\
 &  &  &  &  & (0.20) &  & (0.20) & (0.44) & (0.40)\\
LSAP &  &  &  &  &  & −0.08 & −0.13 & −0.16 & −0.14\\
 &  &  &  &  &  & (0.09) & (0.10) & (0.14) & (0.13)\\
R2 & 0.063 & 0.072 & 0.080 & 0.073 & 0.095 & 0.066 & 0.112 & 0.097 & 0.141\\
R2 Adj. & 0.045 & 0.054 & 0.053 & 0.055 & 0.078 & 0.049 & 0.078 & 0.053 & 0.090\\
\bottomrule
\multicolumn{10}{l}{\rule{0pt}{1em}* p < 0.1, ** p < 0.05, *** p < 0.01}\\
\end{tabular}
\end{table}
    
\end{frame}
\end{document}

我想全局控制表格标题和表格本身之间的空间。我正在使用该caption包并尝试执行此控制,\captionsetup{skip=0pt,belowskip=-5pt}如上所示。

问题在于表格之间的间距不一致,如下所示:

在此处输入图片描述

我希望表 3 的行为在任何地方都一样。表 1 和表 2 不是那样的(它们的标题比另一个高得多),因为被\resizebox{\linewidth}调用了。我不太明白resizebox(这些表格是由 生成的kableR。我的理解是,这在某种程度上破坏了全局调整。

使行为一致的最佳方法是什么?作为参考,我正在使用 XeLaTex 进行编译。

答案1

我不会使用\resizebox,而是减少字体大小和表格中的列间距。此外,对于表格中的数字,使用S列可以使表格看起来更美观。

编辑: 从有问题的 MWE 中添加了最后两帧:

\documentclass[aspectratio=169, xcolor=dvipsnames]{beamer}
\usetheme{Boadilla}
\setbeamertemplate{caption}[numbered]
%
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\SetTblrStyle{caption}{font=\footnotesize}
\SetTblrStyle{caption-tag}{font=\bfseries, blue3}
  \ExplSyntaxOn
\NewChildSelector{eachtwo}
  {
    \int_step_inline:nnnn {2}{2}{\l_tblr_childs_total_tl}
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff
\sisetup{table-format=-1.3{***},
         table-align-text-pre=false,
         table-align-text-post=false,
         input-close-uncertainty=,
         input-open-uncertainty=
         }

\author[]{bla bla bla}
\title{bla bla bla}

% ---- Begin document ----
\begin{document}
\maketitle

\begin{frame}
    \begin{table}
\centering
\tiny
\begin{talltblr}[
caption = {CAPM with local returns},
  label = {tab:talltblr-1},
remark{Note} = {Standard errors in parentheses:\quad
                *: $p < 0.1$, **: $p < 0.05$, ***: $p < 0.01$},
                ]{colsep = {1pt},
                row{2-Z} = {rowsep=0pt},
            row{eachtwo} = {abovesep=1ex},
             }   
    \toprule
    & {{{BusEquip}}}    & {{{Chemicals}}}   & {{{Durables}}}        & {{{Energy}}} 
    & {{{Finance}}}     & {{{Health}}}      & {{{Manufacturing}}}   & {{{NonDurables}}}
    & {{{Other}}}       & {{{Retail}}}      & {{{Telecom}}}         & {{{Utilities}}}\\
    \midrule
SPY Window 
SPY Window 
    & 1.05*** & 1.51*** & 0.38    & 2.25*** & 0.83   & 1.74*** 
    & 1.21*** & 1.49*** & 1.53*** & 1.38*** & 0.93*  & 2.11***  \\
    & (0.40)  & (0.34)  & (0.50)  & (0.55)  & (0.61) & (0.38) 
    & (0.32)  & (0.36)  & (0.33)  & (0.32)  & (0.48) & (0.47)   \\
Surprise 
    & 0.31    & 0.17    & 0.18    & 0.46    & 0.37   & 0.30* 
    & 0.14    & 0.31*   & 0.28    & 0.14    & 0.25   & 0.39*    \\
    & (0.20)  & (0.20)  & (0.25)  & (0.30)  & (0.24) & (0.17) 
    & (0.21)  & (0.17)  & (0.19)  & (0.17)  & (0.18) & (0.21)   \\
Interaction 
    & −0.37   & −0.96*  & 0.56    & −1.55** & −0.34  & −1.29** 
    & −0.35   & −0.97** & −0.87   & −0.75   & −0.56  & −1.48**  \\
    & (0.62)  & (0.54)  & (0.83)  & (0.64)  & (1.02) & (0.54) 
    & (0.66)  & (0.48)  & (0.62)  & (0.62)  & (0.66) & (0.66)   \\
R2  & 0.077   & 0.088   & 0.055   & 0.092   & 0.027  & 0.120 
    & 0.087   & 0.123   & 0.085   & 0.088   & 0.046  & 0.133    \\
R2 Adj. 
    & 0.050   & 0.062   & 0.028   & 0.066   & −0.001 & 0.095 
    & 0.061   & 0.098   & 0.059   & 0.061   & 0.019  & 0.108    \\
\bottomrule
\multicolumn{13}{l}{\rule{0pt}{1em}* p  0.1, ** p < 0.05, *** p < 0.01}\\
\end{tblr}
    \end{table}
\end{frame}

\begin{frame}
    \begin{table}
\centering
\tiny
\begin{talltblr}[
caption = {CAPM with daily SPY returns},
  label = {tab:talltblr-2},
remark{Note} = {Standard errors in parentheses:\quad
                *: $p < 0.1$, **: $p < 0.05$, ***: $p < 0.01$},
                ]{colsep = {1pt},
                 colspec = {@{} Q[l,m] *{12}{X[c, si]} @{}},
                row{2-Z} = {rowsep=0pt},
            row{eachtwo} = {abovesep=1ex},
                 }
    \toprule
    & {{{BusEquip}}}    & {{{Chemicals}}}   & {{{Durables}}}        & {{{Energy}}}
    & {{{Finance}}}     & {{{Health}}}      & {{{Manufacturing}}}   & {{{NonDurables}}}
    & {{{Other}}}       & {{{Retail}}}      & {{{Telecom}}}         & {{{Utilities}}}\\
    \midrule
SPY Daily 
    & 0.64**  & 0.83*** & 0.71*** & 1.03*** & 0.80*** & 0.84*** 
    & 0.79*** & 0.66*** & 0.87*** & 0.74*** & 0.57**  & 0.87*** \\
    & (0.25)  & (0.21)  & (0.20)  & (0.31)  & (0.22)  & (0.23) 
    & (0.23)  & (0.21)  & (0.19)  & (0.17)  & (0.22)  & (0.29)  \\
Surprise 
    & 0.22    & 0.04    & 0.16    & 0.24    & 0.30**  & 0.14 
    & 0.03    & 0.16    & 0.15    & 0.01    & 0.17    & 0.19    \\
    & (0.15)  & (0.13)  & (0.16)  & (0.22)  & (0.14)  & (0.11) 
    & (0.12)  & (0.12)  & (0.11)  & (0.11)  & (0.12)  & (0.15)  \\
{SPY daily:\\ Surprise} 
    & 0.39    & 0.21    & 0.82*** & 0.27    & 0.80*** & −0.02 
    & 0.51**  & 0.16    & 0.38*   & 0.33*   & 0.35    & 0.07    \\
    & (0.26)  & (0.22)  & (0.23)  & (0.28)  & (0.28)  & (0.24) 
    & (0.24)  & (0.22)  & (0.22)  & (0.18)  & (0.24)  & (0.30)  \\
R2  & 0.598   & 0.702   & 0.723   & 0.559   & 0.711   & 0.608 
    & 0.768   & 0.638   & 0.784   & 0.701   & 0.596   & 0.521   \\
R2 Adj. 
    & 0.586   & 0.694   & 0.715   & 0.546   & 0.703   & 0.597 
    & 0.761   & 0.627   & 0.778   & 0.692   & 0.585   & 0.507   \\
    \bottomrule
\end{talltblr}
   \end{table}
\end{frame}

\begin{frame}
    \begin{table}
\centering
\tiny
\begin{talltblr}[
caption = {CAPM with daily SPY returns},
  label = {tab:talltblr-1},
remark{Note} = {Standard errors in parentheses:\quad
                *: $p < 0.1$, **: $p < 0.05$, ***: $p < 0.01$},
                ]{colsep = {3pt},
                 colspec = {@{} l *{9}{X[c, si]} @{}},
                row{2-Z} = {rowsep=0pt},
            row{eachtwo} = {abovesep=1ex},
                 }
    \toprule
    & {{{BK}}}  & {{{NS}}}      & {{{BK + NS}}} & {{{FFR}}} 
    & {{{FG}}}  & {{{LSAP}}}    & {{{JME}}}     & {{{Only MP}}} 
    & {{{All}}} \\
    \midrule
SPY Window 
    & 0.73    & 0.53    & 0.55    & 0.82*   & 0.53    & 0.67 
    & 0.58    &         & 0.71      \\
    & (0.45)  & (0.58)  & (0.57)  & (0.42)  & (0.50)  & (0.42) 
    & (0.55)  &         & (0.47)    \\
BK  & 0.04    &         & 0.12    &         &         &  
    &         & −0.47   & −0.66     \\
    & (0.22)  &         & (0.22)  &         &         &  
    &         & (0.51)  & (0.50)    \\
NS  &         & −0.13   & −0.20   &         &         &  
    &         & 0.05    & 0.07      \\
    &         & (0.19)  & (0.21)  &         &         &  
    &         & (0.48)  & (0.44)    \\
FFR &         &         &         & 0.13    &         &  
    & 0.10    & 0.43    & 0.71      \\
    &         &         &         & (0.23)  &         &  
    & (0.23)  & (0.71)  & (0.70)    \\
FG  &         &         &         &         & −0.22   &  
    & −0.22   & −0.32   & −0.22     \\
    &         &         &         &         & (0.20)  &  
    & (0.20)  & (0.44)  & (0.40)    \\
LSAP 
    &         &         &         &         &         & −0.08 
    & −0.13   & −0.16   & −0.14     \\
    &         &         &         &         &         & (0.09) 
    & (0.10)  & (0.14)  & (0.13)    \\
R2  & 0.063   & 0.072   & 0.080   & 0.073   & 0.095   & 0.066 
    & 0.112   & 0.097   & 0.141     \\
R2 Adj. 
    & 0.045   & 0.054   & 0.053   & 0.055   & 0.078   & 0.049 
    & 0.078   & 0.053   & 0.090     \\
    \bottomrule
\end{talltblr}
    \end{table}
\end{frame}
\end{document}

在此处输入图片描述

相关内容