1

I want to create the following table in the beamer presentation but the command didn't work. Can someone help me to solve this problem? Namely, should I use other packages or what?

\begin{table}
\resizebox{1\textwidth}{!}{
\tempdima=\dimexpr \textwidth/7 - 2\tabcolsep\relax
\small
\begin{tabular}{lccccccc} \hline\hline 
\multicolumn{1}{p{\tempdima}}{Sample window} & 
\multicolumn{1}{p{\tempdima}}{Probability cutoff value} & 
\multicolumn{1}{p{\tempdima}}{Crises correctly called (\%)} & 
\multicolumn{1}{p{\tempdima}}{Non-crises correctly called (\%)} & 
\multicolumn{1}{p{\tempdima}}{Missed crises (\%)} & 
\multicolumn{1}{p{\tempdima}}{False alarm (\%)} &
\multicolumn{1}{p{\tempdima}}{TME}  \\ 

\midrule 

&&& \multicolumn{3}{p{\tempdima}}{In-sample}\\\addlinespace[0.75ex]

1970-2000 & 0.1  &  75.32 & 67.24 & 24.68 & 32.76 & 57.43 \\

1970-2003 & 0.1  & 74.07 & 71.05 & 25.93 & 28.95 & 54.87 \\

1970-2006 & 0.09 & 76.19 & 68.81 & 23.81 & 31.19 & 54.99 \\

1970-2009 & 0.09 & 77.89 & 66.86 & 22.11 & 33.14 & 55.25\\

1970-2012 & 0.09 & 73.68 & 70.85 & 26.32 & 29.15 & 55.46 \\

1970-2015 & 0.09 & 77.14 & 70.45 & 22.86 & 29.55 & 52.40 \\ 

\midrule 

&&&  \multicolumn{3}{p{\tempdima}}{Out-of-sample}   \\

2001-2003 & 0.1 & 75 & 80.95 & 25.00 & 19.05 & 44.04 \\


2004-2006 & 0.1 & 33.33 & 91.86 & 66.67 & 8.14 & 74.80 \\

2007-2009 & 0.09 & 54.55 & 82.89 & 45.45 & 17.11 & 62.55 \\

2010-2012 & 0.09 & 0 & 72.41 & 0 &  27.59 & 27.59 \\

2013-2015 & 0.09 & 80.00 & 74.36 & 20.00 & 25.64 & 45.64 \\

2016-2018 & 0.09 & 66.67 & 87.21 & 33.33 & 12.79 & 46.12 \\  \hline

\end{tabular}}
\caption{3-year ahead in- and out-of-sample prediction}
\label{table: prediction}
\end{table} 

I got the following warning:

enter image description here

4

You

  • not define length `\tempdima˙,
  • forgot on \begin{table}
  • forgot put table in frame
  • forgot to increase width of the multicolumn cell or use c column tape instead of p{\tempdima}

Correcting aforementioned, your table is:

enter image description here

\documentclass{beamer}
\usepackage{booktabs}
\newlength\tempdima

\begin{document}
\begin{frame}
    \begin{table}
\setlength\tempdima{\dimexpr \textwidth/7 - 2\tabcolsep\relax}
\small
\begin{tabular}{lccccccc} \hline\hline
\multicolumn{1}{p{\tempdima}}{Sample window} &
\multicolumn{1}{p{\tempdima}}{Probability cutoff value} &
\multicolumn{1}{p{\tempdima}}{Crises correctly called (\%)} &
\multicolumn{1}{p{\tempdima}}{Non-crises correctly called (\%)} &
\multicolumn{1}{p{\tempdima}}{Missed crises (\%)} &
\multicolumn{1}{p{\tempdima}}{False alarm (\%)} &
\multicolumn{1}{p{\tempdima}}{TME}  \\
    \midrule
&&& \multicolumn{3}{c}{In-sample}   \\
 \addlinespace
1970-2000 & 0.1  &  75.32 & 67.24 & 24.68 & 32.76 & 57.43 \\
1970-2003 & 0.1  & 74.07 & 71.05 & 25.93 & 28.95 & 54.87 \\
1970-2006 & 0.09 & 76.19 & 68.81 & 23.81 & 31.19 & 54.99 \\
1970-2009 & 0.09 & 77.89 & 66.86 & 22.11 & 33.14 & 55.25\\
1970-2012 & 0.09 & 73.68 & 70.85 & 26.32 & 29.15 & 55.46 \\
1970-2015 & 0.09 & 77.14 & 70.45 & 22.86 & 29.55 & 52.40 \\

\midrule
&&&  \multicolumn{3}{c}{Out-of-sample}   \\
2001-2003 & 0.1 & 75 & 80.95 & 25.00 & 19.05 & 44.04 \\
2004-2006 & 0.1 & 33.33 & 91.86 & 66.67 & 8.14 & 74.80 \\
2007-2009 & 0.09 & 54.55 & 82.89 & 45.45 & 17.11 & 62.55 \\
2010-2012 & 0.09 & 0 & 72.41 & 0 &  27.59 & 27.59 \\
2013-2015 & 0.09 & 80.00 & 74.36 & 20.00 & 25.64 & 45.64 \\
2016-2018 & 0.09 & 66.67 & 87.21 & 33.33 & 12.79 & 46.12 \\  \hline
\end{tabular}}
\caption{3-year ahead in- and out-of-sample prediction}
\label{table: prediction}
    \end{table}
\end{frame}
\end{document}

Addendum: You may consider to use tabularx table and S columns type defined in the siunitx package:

\documentclass{beamer}
\usepackage{booktabs, tabularx}
\newcommand\mcx[1]{\multicolumn{1}{>{\centering\arraybackslash}X}{#1}}
\usepackage{siunitx}

\begin{document}
\begin{frame}
    \begin{table}
    \footnotesize
    \setlength\tabcolsep{2pt}
\begin{tabularx}{\linewidth}{@{} l *{6}{S[table-format=2.2]} @{}} 
    \toprule
\mcx{Sample window} &
\mcx{Probability cutoff value} &
\mcx{Crises correctly called (\%)} &
\mcx{Non-crises correctly called (\%)} &
\mcx{Missed crises (\%)} &
\mcx{False alarm (\%)} &
\mcx{TME}  \\
    \midrule
& \multicolumn{6}{c}{In-sample}   \\
 \addlinespace
1970-2000 & 0.1  &  75.32 & 67.24 & 24.68 & 32.76 & 57.43 \\
1970-2003 & 0.1  & 74.07 & 71.05 & 25.93 & 28.95 & 54.87 \\
1970-2006 & 0.09 & 76.19 & 68.81 & 23.81 & 31.19 & 54.99 \\
1970-2009 & 0.09 & 77.89 & 66.86 & 22.11 & 33.14 & 55.25\\
1970-2012 & 0.09 & 73.68 & 70.85 & 26.32 & 29.15 & 55.46 \\
1970-2015 & 0.09 & 77.14 & 70.45 & 22.86 & 29.55 & 52.40 \\
    \midrule
    \addlinespace
&  \multicolumn{6}{c}{Out-of-sample}   \\
2001-2003 & 0.1 & 75 & 80.95 & 25.00 & 19.05 & 44.04 \\
2004-2006 & 0.1 & 33.33 & 91.86 & 66.67 & 8.14 & 74.80 \\
2007-2009 & 0.09 & 54.55 & 82.89 & 45.45 & 17.11 & 62.55 \\
2010-2012 & 0.09 & 0 & 72.41 & 0 &  27.59 & 27.59 \\
2013-2015 & 0.09 & 80.00 & 74.36 & 20.00 & 25.64 & 45.64 \\
2016-2018 & 0.09 & 66.67 & 87.21 & 33.33 & 12.79 & 46.12 \\  
    \bottomrule
\end{tabularx}
\caption{3-year ahead in- and out-of-sample prediction}
\label{table: prediction}
    \end{table}
\end{frame}
\end{document}

which gives:

enter image description here

| improve this answer | |
  • The command works very well. I h just want to let the table continue on the next page since this is bigger than the table I posted here. Can you help me with the command? – Arbnor May 25 at 12:59
  • 2
    @Arbnor, multi page table in beamer?In presentation are tables boring ... Regard this, please ask new question. However, since my answer solve your problem, it will be nice from you, if you would up-vote and answer and even accept it (by clicking on up-pen and check mark at top left side of answer. As I see, so far you not do this at any received answer :-( – Zarko May 25 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.