[Tex/LaTex] Including Large Tables in a beamer Frame

beamertables

What is the best way of including large tables in a beamer presentation?

Best Answer

If you must include a large table in your presentation, you have a couple of options:

  • Construct the table as is necessary and resize it to fit within the actual frame by scaling it down. This is easily obtainable via \resizebox{<width>}{<height>}{<stuff>} from the graphicx package. In order to maintain the correct aspect ratio, specify the one length and make the other !. Here is a visualization:

    enter image description here

    \documentclass{beamer}% http://ctan.org/pkg/beamer
    \usepackage{graphicx}% http://ctan.org/pkg/graphicx
    \usepackage{booktabs}% http://ctan.org/pkg/booktabs
    \begin{document}
    \begin{frame}
      \frametitle{This is a frame with a table}
      \begin{tabular}{*{27}{l}}
        \toprule
        Stuff & A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z \\
        \midrule
        One   & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Two   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Three & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Four  & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Five  & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Six   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Seven & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \bottomrule
      \end{tabular}
    \end{frame}
    
    \begin{frame}
      \frametitle{This is a frame with a table}
      \resizebox{\linewidth}{!}{% Resize table to fit within \linewidth horizontally
      \begin{tabular}{*{27}{l}}
        \toprule
        Stuff & A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z \\
        \midrule
        One   & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Two   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Three & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Four  & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Five  & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Six   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Seven & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \bottomrule
      \end{tabular}}
    \end{frame}
    
    \end{document}
    
  • You could break your table up into parts by only showing certain columns on certain slides. Another visualization:

    enter image description here

    \documentclass{beamer}% http://ctan.org/pkg/beamer
    \usepackage{booktabs}% http://ctan.org/pkg/booktabs
    \usepackage{array}% http://ctan.org/pkg/array
    \newsavebox{\mybox}% Store some content in a box
    \newcolumntype{G}{@{}>{\begin{lrbox}{\mybox}}l<{\end{lrbox}}@{}}% a column that Gobbles it's entries
    \begin{document}
    \begin{frame}
      \frametitle{This is a frame with a table}
      \begin{tabular}{*{14}{@{\hspace{2pt}}l@{\hspace{2pt}}}*{13}{G}}
        \toprule
        Stuff & A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z \\
        \midrule
        One   & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Two   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Three & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Four  & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Five  & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Six   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Seven & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \bottomrule
      \end{tabular}
    \end{frame}
    
    \begin{frame}
      \frametitle{This is a frame with a table}
      \begin{tabular}{@{\hspace{2pt}}l@{\hspace{2pt}}*{13}{G}*{13}{@{\hspace{2pt}}l@{\hspace{2pt}}}}
        \toprule
        Stuff & A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z \\
        \midrule
        One   & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Two   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Three & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Four  & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Five  & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Six   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Seven & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \bottomrule
      \end{tabular}
    \end{frame}
    
    \end{document}
    

    The advantage with an approach like this is that you code your entire table the way you want to, but selectively show the columns of interest. While row-removal from a table is easy (you either comment them out using %, or delete them outright), column deletion is not that easy.

  • Use beamer's zooming capability. From the beamer documentation on 11.3 Adding Anticipated zooming (p 109):

    Anticipated zooming is necessary when you have a very complicated graphic that you are not willing to simplify since, indeed, all the complex details merit an explanation. In this case, use the command \framezoom. It allows you to specify that clicking on a certain area of a frame should zoom out this area. You can then explain the details. Clicking on the zoomed out picture will take you back to the original one.

    In the above description, "graphic" might just as well have read "object", since it pertains to tables as well.

    For the sake of illustration, I've highlighted a couple of entries (in red \alert font) within the same table I've used before, this time also shrunk down using \resizebox and then zoomed in on them using \framezoom.

    enter image description here

    \documentclass{beamer}% http://ctan.org/pkg/beamer
    \usepackage{graphicx}% http://ctan.org/pkg/graphicx
    \usepackage{booktabs}% http://ctan.org/pkg/booktabs
    \begin{document}
    \begin{frame}
      \frametitle{This is a frame with a table}
    
      \framezoom<1><2>[border=1](0pt,11mm)(4.5em,5ex)
    
      \resizebox{\linewidth}{!}{% Resize table to fit within \linewidth horizontally
      \begin{tabular}{*{27}{l}}
        \toprule
        Stuff & A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z \\
        \midrule
        One   & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Two   & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Three & 1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \alert{Four}  & 26&25&24&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Five  & 1&\alert{2}&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        Six   & 26&25&\alert{24}&23&22&21&20&19&18&17&16&15&14&13&12&11&10&9&8&7&6&5&4&3&2&1 \\
        Seven & \alert{1}&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16&17&18&19&20&21&22&23&24&25&26 \\
        \bottomrule
      \end{tabular}}
    \end{frame}
    
    \end{document}
    

    In the above example, the border was inserted/kept for clarity. However, by default (if you remove the border=<n> option), it will not be displayed. \framezoom has the following syntax:

    \framezoom<button overlay spec><zoomed overlay spec>[<options>](<ulx>,uly>)(<zoom width>,<zoom depth>)
    

    As such, I requested a zoom of slide <1>, upon clicking, to be typeset on slide <2>, adding an optional [border=1] of 1pt. The zoomed location on slide <1> is at coordinate (<ulx>,<uly>)=(0pt,11mm) and spans an area of (<width>,<depth>)=(4.5em,5ex).