Beamer: resize regression table to vertically fit the frame

beamerresizetables

I'm using the beamer class to make presentations and my regression tables aren't fitting vertically in the frame. I've tried using \tiny before the tabular environment. Even then a part of table isn't fitting in the frame.

\begin{frame}{Results}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{\tiny Effect of x on y}
\tiny
\begin{tabular}{l*{2}{c}}
\hline\hline
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
            &\multicolumn{1}{c}{y1}&\multicolumn{1}{c}{y2}\\
\hline
1.x&      0.03** &      0.03*  \\
            &    (0.157)   &    (0.62)   \\
[1em]
1.hg&      0.16   &               \\
            &    (0.84)   &               \\
[1em]
1.f#1.hg&     -0.6*  &               \\
            &    (0.8)   &               \\
[1em]
1.i&      0.9   &    -0.1   \\
            &    (0.30)   &    (0.36)   \\
[1em]
1.i#1.hg&      0.167   &               \\
            &    (0.200)   &               \\
[1em]
2.year     &      0.63** &      0.03***\\
            &    (0.15)   &    (0.12)   \\
[1em]
3.year     &      0.07***&      0.17   \\
            &    (0.011)   &    (0.01)   \\
[1em]
1.h &               &      0.72** \\
            &               &    (0.32)   \\
[1em]
1.f#1.h &               &     -0.49*  \\
            &               &    (0.25)   \\
[1em]
1.i#1.h &               &     -0.327   \\
            &               &    (0.26)   \\
[1em]
\_cons      &       0.62***&     -0.088   \\
            &    (0.54)   &    (0.59)   \\
\hline
N           &        500   &        455   \\
FE&         Yes   &         Yes   \\
Control &         Yes   &         Yes   \\
\hline\hline
\multicolumn{3}{l}{\tiny Standard errors in parentheses}\\
\multicolumn{3}{l}{\tiny * p<0.10, ** p<0.05, *** p<0.01}\\
\end{tabular}
\end{table}


\end{frame}

i also tried resizing vertically with \resizebox{!}{\textwidth} but it didn't work.

Can someone suggest how to solve this issue?
Thanks

Best Answer

What about this redesign?

enter image description here

\documentclass{beamer}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{frame}{Results}

\begin{table}[htbp]
\centering
\caption{Effect of x on y}
\footnotesize
\sisetup{table-format=-1.2, table-space-text-post={***}, table-align-text-post=false}
\begin{tabular}{l Sl Sl}
\toprule
          & \multicolumn{2}{c}{(1) y1} & \multicolumn{2}{c}{(2) y2}\\
\cmidrule(r){2-3} \cmidrule(l){4-5}
1.x       &  0.03**  & (0.157)         & 0.03*    & (0.62) \\
1.hg      &  0.16    & (0.84)          &          &        \\
1.f\#1.hg & -0.6*    & (0.8)           &          &        \\
1.i       &  0.9     & (0.30)          & -0.1     & (0.36) \\
1.i\#1.hg &  0.167   & (0.200)         &          &        \\
2.year    &  0.63**  & (0.15)          & 0.03***  & (0.12) \\
3.year    &  0.07*** & (0.011)         & 0.17     & (0.01) \\
1.h       &          &                 & 0.72**   & (0.32) \\
1.f\#1.h  &          &                 & -0.49*   & (0.25) \\
1.i\#1.h  &          &                 & -0.327   & (0.26) \\       
\_cons    &  0.62*** & (0.54)          & -0.088   & (0.59) \\
\cmidrule(r){2-3} \cmidrule(l){4-5}
N         & \multicolumn{2}{c}{500}    & \multicolumn{2}{c}{455}  \\
FE        & \multicolumn{2}{c}{Yes}    & \multicolumn{2}{c}{Yes}  \\
Control   & \multicolumn{2}{c}{Yes}    & \multicolumn{2}{c}{Yes}  \\
\bottomrule
\multicolumn{5}{l}{\scriptsize Standard errors in parentheses}\\
\multicolumn{5}{l}{\scriptsize  * p<0.10, ** p<0.05, *** p<0.01}\\
\end{tabular}
\end{table}

\end{frame}

\end{document}
Related Question