2

I am trying to make a big table fit into a beamer slide. My table has 2 panels which are 2 tabularx environments. My attempt involves one \resizebox for each tabularx environment (see code below).

If I put the 2 tabularx in the same \resizebox, then I get an error because I'm using \\ [0.3cm] to have some space between the 2 panels. I'm wondering whether there exists a better solution than this.

Any help would be highly appreciated. enter image description here

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tabularx,booktabs,dcolumn}
\pdfmapfile{+sansmathaccent.map}
\newcolumntype{d}{D..{-1}}
\begin{document}

\begin{frame}
\frametitle{Title of my slide}
\begin{table}
\tiny
\begin{tabular}{c*{7}{d}}
\midrule
\multicolumn{1}{c}{$CCCCC$}
 & \multicolumn{1}{c}{$CCCCC$}
 & \multicolumn{1}{c}{$CCCC$}
 & \multicolumn{1}{c}{$CCC$}
 & \multicolumn{1}{c}{$CCCCCCC$}
 & \multicolumn{1}{c}{$CCCCCC$}
 & \multicolumn{1}{c}{$CCCCCC$}
 & \multicolumn{1}{c}{$CCCCCCCCCCCCCC$}
 \\
 \midrule

 \multicolumn{8}{c}{\textbf{Panel A: AAA}} \\
 \midrule
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
  & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
  &       &       &       &       &       &       &  \\
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
  & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
  &       &       &       &       &       &       &  \\
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
  & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\ 
  \end{tabular}

 \vfill


 \begin{tabular}{c*{7}{d}}

 \multicolumn{8}{c}{\textbf{Panel B: BBB}} \\
 \midrule
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
   & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
   &       &       &       &       &       &       &  \\
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
   & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
   &       &       &       &       &       &       &  \\
  0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
   & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\ 
  \midrule
  \end{tabular}

  \end{table}
  \end{frame}



 \end{document}  
4
  • Welcome to TeX.SX! A tip: You can use backticks ` to mark your inline code as I did in my edit.
    – adn
    Apr 22, 2015 at 14:07
  • \\[0.3cm] % space between panels is wrong. use \bigskip or \vspace{.3cm} or whatever Apr 22, 2015 at 14:15
  • \resizebox{8cm}{!} { \begin{tabularx}{\linewidth} you are making tabularx force the table width to be \textwidth then scaling it (and two word spaces) to 8cm? Why not set the table to the desired size without scaling? Apr 22, 2015 at 14:17
  • Alternatively, if you're going to resize the entire content, you could also wrap all the frame content in a { \tiny \begin{table}[htb] ... \end{table} } group. Apr 22, 2015 at 14:19

1 Answer 1

3

I would try to avoid scaling tables, and avoid using tabularx for numeric data (tabularx adjusts column widths by changing the target width for line breaking but you don't normally want line breaking within cells for this kind of table)

enter image description here

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tabularx,booktabs,dcolumn}
\pdfmapfile{+sansmathaccent.map}
%\usepackage{graphicx}
%\usepackage{adjustbox}
\newcolumntype{d}{D..{-1}}
\begin{document}
\begin{frame}
\frametitle{Title of my slide}
\begin{table}
\tiny
\begin{tabular}{c*{7}{d}}
\midrule
 \multicolumn{1}{c}{$CC1$}
& \multicolumn{1}{c}{$CC2$}
& \multicolumn{1}{c}{$CC3$}
& \multicolumn{1}{c}{$CC4$}
& \multicolumn{1}{c}{$CC5$}
& \multicolumn{1}{c}{$CC6$}
& \multicolumn{1}{c}{$CC7$}
& \multicolumn{1}{c}{$CC8$}
\\
\midrule

\multicolumn{8}{c}{\textbf{Panel A: AAA}} \\
\midrule
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
      & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
      &       &       &       &       &       &       &  \\
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
      & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
      &       &       &       &       &       &       &  \\
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
      & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\ 
 \end{tabular}


\vfill


\begin{tabular}{c*{7}{d}}
\multicolumn{8}{c}{\textbf{Panel B: BBB}} \\
\midrule
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
       & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
       &       &       &       &       &       &       &  \\
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
       & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\
       &       &       &       &       &       &       &  \\
 0     & 0.00  & 0.00  & 0.00 & 0.00 & 0.00  & 0.00 & 0.00 \\
       & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) & (0.00) \\ 
 \midrule
 \end{tabular}


 \end{table}
 \end{frame}
 \end{document} 
3
  • Dear David, thanks a lot for your precious help. May I ask one last thing? I notice that I have columns titles slightly longer than 2 characters, the column titles are not aligned. Suppose I have: $CCCC1$ & $CCC2$ & $CCC3$ & $CCC4$ & $CCC5$ & $CCC6$ & $CCCCC7$ & $CCCC8$ \\ Apr 22, 2015 at 16:23
  • @user3618451 answer updated to use c formatting rather than d for the header row. Apr 22, 2015 at 16:31
  • David, thanks again for your answer. I have updated the initial code. I still have troubles when the column titles are really long. The 2nd panel has a smaller width than the first one. I'm also attaching an image this time. Apr 22, 2015 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .