A long table can’t fit in beamer’s frame

beamerlongtable

Question:

I have been preparing beamer presentation which is in last stage where I wish to insert a long table but unfortunately I couldn't find the solution. Please guide me.. Please…

Thanks in advance……..

MWE:

\documentclass[12pt]{beamer}
\usepackage{ragged2e}\justifying
\usepackage{xcolor}
\usepackage{hyperref}
\usetheme{AnnArbor}
%%================================
\usepackage[f]{esvect}
\usecolortheme{beaver}% red color theme
\usefonttheme{professionalfonts} % using non standard fonts for beamer
%%----------------------------------------------------------
\usepackage{makecell, multirow}
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}\bfseries}
%%-----------------------------------------------------------
\usepackage[skip=1ex, font=small, labelfont=bf]{caption}
\usefonttheme{serif} % default family is serif
\usepackage{setspace}
\usepackage{lipsum}
\addtobeamertemplate{frametitle}{}{\vspace{-0.4em}} % decrease
\setlength{\parskip}{5pt}
\title[]{\footnotesize{\textbf{My Title}}}
\subtitle{}
\author[]{}
\institute[]{}
\date[]{\textbf{\today}}
%%=================
\begin{document}
\begin{frame}[plain, noframenumbering]
 \maketitle  
\end{frame}
%%------------------------------------------------------------
\begin{frame}[t]{}
\begin{table}[ht]
    \centering
\sisetup{detect-weight,
         mode=text}
    \setcellgapes{5pt}
    \makegapedcells
\caption{My table}
\label{tab:...}
    \label{tab:my-table}
\begin{tabular}{|*{5}{S[table-format=1.1]|}
                 *{2}{S[table-format=-1.11]|}
                 }
\hline
{\multirow{2.4}{*}{A}} & {\multirow{2.4}{*}{B}} & {\multirow{2.4}{*}{C}} & {\multirow{2.4}{*}{D}} & {\multirow{2.4}{*}{E}} & \multicolumn{2}{c|}{F}         \\ \cline{6-7}
        &       &       &       &       & {G}           & {H}           \\  \hline
\B  0.2 &\B 0.5 &\B 1   &\B 0.2 &\B 0.5 & -1.8713360906 & -1.7640262021 \\ \hline
\B  0.3 & 0.5   & 1     & 0.2   & 0.5   & -1.9365758323 & -1.7648755545 \\ \hline
\B  0.4 & 0.5   & 1     & 0.2   & 0.5   & -1.9844365775 & -1.7572640364 \\ \hline
0.2     &\B 0.6 & 1     & 0.2   & 0.5   & -1.8893451634 & -1.7769110253 \\ \hline
0.2     &\B 0.7 & 1     & 0.2   & 0.5   & -1.9037201042 & -1.7845630194 \\ \hline
0.2     &\B 0.8 & 1     & 0.2   & 0.5   & -1.9084283289 & -1.78054097011    \\ \hline
0.2     & 0.5   &\B 1.1 & 0.2   & 0.5   & -1.8638586434 & -1.75716821872    \\ \hline
0.2     & 0.5   &\B 1.2 & 0.2   & 0.5   & -1.8563791180 & -1.75030388119    \\ \hline
0.2     & 0.5   &\B 1.3 & 0.2   & 0.5   & -1.8488975550 & -1.74343325690    \\ \hline
0.2     & 0.5   & 1     &\B 0.3 & 0.5   & -1.7816929512 & -1.67995077275    \\ \hline
0.2     & 0.5   & 1     &\B 0.4 & 0.5   & -1.6940695909 & -1.59754625788    \\ \hline
0.2     & 0.5   & 1     &\B 0.5 & 0.5   & -1.60833298231& -1.51669912930    \\ \hline
0.2     & 0.5   & 1     & 0.2   &\B 0.6 & -1.79104380621& -1.69665633242    \\ \hline
0.2     & 0.5   & 1     & 0.2   &\B 0.7 & -1.72028938675& -1.63324789889    \\ \hline
0.2     & 0.5   & 1     & 0.2   &\B 0.8 & -1.66248454886& -1.58021088372    \\ \hline
\end{tabular}
    \end{table}
\end{frame}
%%------------------------------------------------------------
\end{document}

Best Answer

Another possible solution is use for table the tabularray package. Its use has a some specifics, hence a new answer.

Using tabularray a text in column headers, when it contain letters d, D, e or E, interact with S specification and throw an error. This can be solved on two ways:

  • if numbers in tables not contain exponents (like 12.34e-6), than you can remove from S column specifications those exponent markers by option input-exponent-markers= (as is used in MWE below)
  • another way (more recommended) is encapsulate column header in two curly braces. for example \SetCell[r=2]{c} {{D}} or \SetCell[c=2]{c} {{E}}.

In the first case the MWE is:

\documentclass[12pt]{beamer}
\usetheme{AnnArbor}
\usecolortheme{beaver}% red color theme
\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
%----
    \setbeamerfont{title page}{size=\small\bfseries}
    \setbeamerfont{subtitle}{size=\scriptsize\bfseries}
%----
    \setbeamerfont{frametitle}{size=\footnotesize\bfseries}
%----
    \setbeamertemplate{caption}[numbered]
\usepackage[font=scriptsize,
            labelfont={bf,color=blue}]
            {caption}% it is compatible with the last beamer versions
%---------------------------------------------------------------%
\usepackage{ragged2e}\justifying
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\setlength{\parskip}{5pt}
\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}\bfseries\color{teal}}
\AtBeginEnvironment{table}{\setlength{\parskip}{-5pt}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\title[Presentation title]{Presentation title}
\subtitle{Example of use the \texttt{tabularray} package}
\author[zfc]{Math-Man}
\institute[]{}
\date{\today}
%---------------------------------------------------------------%

\begin{document}
\begin{frame}[plain, noframenumbering]
    \maketitle
\end{frame}

%---------------------------------------------------------------%
\section{Result}
\subsection{Simulations}
%---------------------------------------------------------------%

\begin{frame}[t]% no frame title
\begin{table}
    \centering
\sisetup{detect-weight,
         mode=text,
         input-exponent-markers=}   % <===
\caption{My table}
\label{tab:tblr}
    \footnotesize
\begin{tblr}{hlines, vlines,
             colspec={*{5}{ S[table-format=1.1] }
                      *{2}{ S[table-format=-1.11]} },
             colsep=4pt,
             abovesep={ 0.5pt},     % <---
             belowsep={-0.5pt}      % <---
                 }
\SetCell[r=2]{c} A
        &   \SetCell[r=2]{c} B
                &   \SetCell[r=2]{c} C
                        &   \SetCell[r=2]{c} D
                                &   \SetCell[r=2]{c} E
                                        &   \SetCell[c=2]{c} F
                                                        &                   \\
        &       &       &       &       &   {{{G}}}     &   {{{H}}}         \\
\B  0.2 &\B 0.5 &\B 1   &\B 0.2 &\B 0.5 & -1.8713360906 & -1.7640262021     \\
\B  0.3 & 0.5   & 1     & 0.2   & 0.5   & -1.9365758323 & -1.7648755545     \\
\B  0.4 & 0.5   & 1     & 0.2   & 0.5   & -1.9844365775 & -1.7572640364     \\
0.2     &\B 0.6 & 1     & 0.2   & 0.5   & -1.8893451634 & -1.7769110253     \\
0.2     &\B 0.7 & 1     & 0.2   & 0.5   & -1.9037201042 & -1.7845630194     \\
0.2     &\B 0.8 & 1     & 0.2   & 0.5   & -1.9084283289 & -1.78054097011    \\
0.2     & 0.5   &\B 1.1 & 0.2   & 0.5   & -1.8638586434 & -1.75716821872    \\
0.2     & 0.5   &\B 1.2 & 0.2   & 0.5   & -1.8563791180 & -1.75030388119    \\
0.2     & 0.5   &\B 1.3 & 0.2   & 0.5   & -1.8488975550 & -1.74343325690    \\
0.2     & 0.5   & 1     &\B 0.3 & 0.5   & -1.7816929512 & -1.67995077275    \\
0.2     & 0.5   & 1     &\B 0.4 & 0.5   & -1.6940695909 & -1.59754625788    \\
0.2     & 0.5   & 1     &\B 0.5 & 0.5   & -1.60833298231& -1.51669912930    \\
0.2     & 0.5   & 1     & 0.2   &\B 0.6 & -1.79104380621& -1.69665633242    \\
0.2     & 0.5   & 1     & 0.2   &\B 0.7 & -1.72028938675& -1.63324789889    \\
0.2     & 0.5   & 1     & 0.2   &\B 0.8 & -1.66248454886& -1.58021088372    \\
\end{tblr}
    \end{table}
\end{frame}
\end{document}

in the second case the table preamble and column headers are:

\begin{table}
    \centering
\sisetup{detect-weight,
         mode=text} 
\caption{My table}
\label{tab:tblr}
    \footnotesize
\begin{tblr}{hlines, vlines,
             colspec={*{5}{ S[table-format=1.1] }
                      *{2}{ S[table-format=-1.11]} },
             colsep=4pt,
             abovesep={ 0.5pt},     % <---
             belowsep={-0.5pt}      % <---
                 }
\SetCell[r=2]{c} A
        &   \SetCell[r=2]{c} B
                &   \SetCell[r=2]{c} C
                        &   \SetCell[r=2]{c} {{D}}  % <---
                                &   \SetCell[r=2]{c} {{E}}  % <---
                                        &   \SetCell[c=2]{c} F
                                                        &                   \\
        &       &       &       &       &   {{{G}}}     &   {{{H}}}         \\

In both cases result of compilation are the same:

enter image description here

Note: In comparison to the first answer here in table are used bigger font size, i.e. instead \scriptsize is used \footnotesize.

Related Question