2

I found that the table in normal latexpdf file displays very well-formulated, however when I copy it into a beamer, the numbers inside are overlapped. I tried to use the $\scalebox$, but it does not work. Could anybody give me a help? Thank you. enter image description here

\documentclass{beamer}
 \usepackage{tabularx} 
  \usepackage{geometry}
    \usepackage{ragged2e}
 \usetheme{Madrid}
 \usepackage{tabularx, makecell, caption} 



% Let's get started
\begin{document}
\begin{frame}{simulation study}
 \begin{itemize}
     \item AUC values obtained by the six esitmators

 \scalebox{0.9}{   
  \begin{tabularx}{\linewidth}{>{\RaggedRight\arraybackslash}X*{6}{|>{\RaggedRight\arraybackslash}X}}
  \Xhline{0.8pt}
%  \cline{1-8}
  & \makecell[lc]{MLE \\ (AUC) } 
& \makecell[lc]{ Ridge \\ (AUC)  } 
&\makecell[lc]{ Lasso \\ (AUC) }  & \makecell[lc]{ James-Stein\\ (AUC) }    &  \makecell[lc]{ EBayes  \\ (AUC) }  & \makecell[lc]{EBayes2\\ (AUC)} \\
\hline

Scenario 1
 &\makecell{$0.88\pm 0.05$}&\makecell{$0.88 \pm 0.05$}&\makecell{$0.68\pm0.06$ }&\makecell{$0.87\pm0.06$ } &\makecell{$0.89\pm0.05$   }&\makecell{$0.87\pm 0.06$   }\\
\hline
Scenario 2 &\makecell{$ 0.95\pm0.02$ }&\makecell{$ 0.95\pm0.02$ }&\makecell{$0.69\pm0.04$ }&\makecell{$ 0.96\pm0.02$ } &\makecell{$ 0.98\pm0.01$   }&\makecell{$ 0.98\pm0.01$   }\\
\hline
\end{tabularx}

\hfill \break
  }
  \item the number of selected SNPs 
 \begin{tabularx}{\linewidth}{>{\RaggedRight\arraybackslash}X*{6}{|>{\hsize=0.85\hsize\RaggedRight\arraybackslash}X}}
  \Xhline{0.8pt}
%  \cline{1-8}
  & \makecell[lc]{MLE   }  
& \makecell[lc]{ Ridge   }  
&\makecell[lc]{ Lasso  }  & \makecell[lc]{ James-Stein }    &  \makecell[lc]{ EBayes   }  & \makecell[lc]{EBayes2} \\
\hline 

 \makecell[lc]{SNPs selected}
 &\makecell{90}&\makecell{90}&\makecell{91}&\makecell{5} &\makecell{5}&\makecell{10 }\\
\hline

\end{tabularx}

\hfill \break
 \end{itemize}
\end{frame}


\end{document}

Re-edit, my further question given the solution (first formatting case), how to control the size of the first column? I modify according to the codes of first formatting case, which gives the result

enter image description here

I believe that the problem lies in the first column, if I can adapt the text of the first column, then the problem solved. Could you further indicate me how to modify it?

\documentclass{beamer}
 \usepackage{tabularx} 
  \usepackage{geometry}
    \usepackage{ragged2e}
 \usetheme{Madrid}
 \usepackage{tabularx, makecell, caption} 



    % Let's get started
    \begin{document}

    \begin{frame}{Real data application}
     \footnotesize
     \sisetup{separate-uncertainty,
              table-format=2.2(2)}
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                                 c*{7}{S}
                                 }
        \midrule[0.7pt]
    %  \cline{1-8}
    Endpoints  &  {MLE   }  
    &  { Ridge  }  
    & { Lasso }  &  { James-Stein}    &   { EBayes  }  &  {EBayes2   } \\
    \hline 
    \makecell[lc]{GI mucus\\ loss}    &  0.70 (0.12) & 0.70(0.12) &0.69(0.09)&0.67(0.15)&0.65(0.10) &1.00(0.00)     \\\midrule

    GI RBPA  &0.55(0,13)&0.55(0.13)&0.55(0.17)&0.63(0.14) &0.72(0.12)&1.00(0.00)
     \\\midrule

    GU diarrhea  &0.56(0.16)&0.56(0.16)&0.60(0.16)&0.64(0.11) &0.72(0.18) &1.00(0.00)  \\\midrule

    GI nocturia  &0.55(0.09)&0.55(0.09)&0.54(0.08)&0.57(0.10) &0.52(0.05) &0.79(0.07)  \\\addlinespace



    GU urgency &0.71(0.07)&0.71(0.07)&0.70(0.09)&0.67(0.06) &0.57(0.10)&0.96(0.03)\\\bottomrule
    % \hline
    \end{tabular*}

    \end{frame}
\end{document}
4

Your table is too big to fit in the available space of the frame. In my opinion the only way is redesign the table:

  • use siunitx package for number formatting in the table
  • use a smaller font
  • consider using standard notation for uncertainty

enter image description here

\documentclass{beamer}
 \usetheme{Madrid}
\usepackage{siunitx}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, tabularx}

% Let's get started
\begin{document}
\begin{frame}{simulation study (1. formatting case)}
\setlength\tabcolsep{0pt}
    \begin{itemize}
\item   AUC values obtained by the six estimators (AUC)
{\footnotesize
 \sisetup{separate-uncertainty,
          table-format=2.2(2)}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             c*{7}{S}
                             }
    \midrule[0.6pt]
Scenario
    & {MLE}         & {Ridge}       & {Lasso}
    & {James-Stein} & {EBayes}      & {EBayes2}     \\
    \midrule
1   & 0.88(5)       & 0.88(5)       & 0.68(6)
    & 0.87(6)       & 0.89(5)       & 0.87(6)       \\
    \addlinespace
2   & 0.95(2)       & 0.95(2)       & 0.69(4)
    & 0.96(2)       & 0.98(1)       & 0.98(1)       \\
    \bottomrule
\end{tabular*}
}

\item   the number of selected SNPs
{\footnotesize
 \sisetup{table-format=5.4}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             c*{7}{S}
                             }
    \midrule[0.6pt]
    &  {MLE}        &  {Ridge}      &  {Lasso}
    &  {James-Stein}&  {EBayes}     &  {EBayes2}    \\
    \midrule
\makecell[lc]{SNPs\\ selected}
    &  90           &   90          &   91
    &  5            &   5           &   10          \\
    \bottomrule
\end{tabular*}
}
    \end{itemize}
\end{frame}

\begin{frame}{simulation study (2. formatting case)}
\setlength\tabcolsep{0pt}
    \begin{itemize}
\item   AUC values obtained by the six estimators (AUC)
{\small
 \sisetup{table-format=2.2(2)}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             c*{7}{S}
                             }
    \midrule[0.6pt]
Scenario
    & {MLE}         & {Ridge}       & {Lasso}
    & {James-Stein} & {EBayes}      & {EBayes2}     \\
    \midrule
1   & 0.88(5)       & 0.88(5)       & 0.68(6)
    & 0.87(6)       & 0.89(5)       & 0.87(6)       \\
    \addlinespace
2   & 0.95(2)       & 0.95(2)       & 0.69(4)
    & 0.96(2)       & 0.98(1)       & 0.98(1)       \\
    \bottomrule
\end{tabular*}
}

\item   the number of selected SNPs
{\small
 \sisetup{table-format=5.4}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             c*{7}{S}
                             }
    \midrule[0.6pt]
    &  {MLE}        &  {Ridge}      &  {Lasso}
    &  {James-Stein}&  {EBayes}     &  {EBayes2}    \\
    \midrule
\makecell[lc]{SNPs\\ selected}
    &  90           &   90          &   91
    &  5            &   5           &   10          \\
    \bottomrule
\end{tabular*}
}
    \end{itemize}
\end{frame}
\end{document}

edit: a possible solution example, which consider your comment below in cases, that you have longer texts in the first column and you like to break into more lines, then as solution is use column type p{<length>} for it. for example:

 \sisetup{separate-uncertainty,
          table-format=1.2(2)}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             p{8ex} *{7}{S}
                             }

however, result with this change become leas beautiful as it is now. for example see second table on frame and imagine, that text in the first column has four lines :-(

as possible solution is use threeparttable: \documentclass{beamer} \usetheme{Madrid} \usepackage{siunitx} \usepackage{ragged2e} \usepackage{booktabs, threeparttable}% <-------

% Let's get started
\begin{document}
\begin{frame}{simulation study (1. formatting case)}
\setlength\tabcolsep{0pt}
    \begin{itemize}
\item   AUC values obtained by the six estimators (AUC)
{\footnotesize
 \sisetup{separate-uncertainty,
          table-format=1.2(2)}% <-------
\begin{threeparttable}% <-------          
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             p{8ex}*{7}{S}
                             }
    \midrule[0.8pt]
Scenario
            & {MLE}         & {Ridge}       & {Lasso}
            & {James-Stein} & {EBayes}      & {EBayes2}     \\
    \midrule
1\tnote{a}  & 0.88(5)       & 0.88(5)       & 0.68(6)
            & 0.87(6)       & 0.89(5)       & 0.87(6)       \\
    \addlinespace
2\tnote{b}  & 0.95(2)       & 0.95(2)       & 0.69(4)
            & 0.96(2)       & 0.98(1)       & 0.98(1)       \\
    \bottomrule
\end{tabular*}
    \begin{tablenotes}[para, flushleft]\scriptsize   % <-------
\item[a]    put long text of the \textbf{a} cell here% <-------
\item[b]    put long text of the \textbf{b} cell here% <-------
    \end{tablenotes}                                 % <-------
\end{threeparttable} % <-------
}   \\[\baselineskip]% <-------

\item   the number of selected SNPs\smallskip% <-------
{\footnotesize
 \sisetup{table-format=5.4}
\begin{threeparttable}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             c*{7}{S}
                             }
    \midrule[0.8pt]
    &  {MLE}        &  {Ridge}      &  {Lasso}
    &  {James-Stein}&  {EBayes}     &  {EBayes2}    \\
    \midrule
SNPs\tnote{a}
    &  90           &   90          &   91
    &  5            &   5           &   10          \\
    \bottomrule
\end{tabular*}
    \begin{tablenotes}[para, flushleft]\scriptsize
\item[a]    SNPs selected
    \end{tablenotes}
\end{threeparttable}
}
    \end{itemize}
\end{frame}
\end{document}

which gives:

enter image description here

  • Thank you! But I have a further question which I think it is not necessary to open a new question. I prefer the first formatting case, so I plan to apply it. I also want to apply it to another similar table, but the problem is that the first column of the new table has long text than the example in my question. When I modify your codes (first formatting codes), it does work. But the only difference lies in the first column, which contains more text. So I re-edit my question and would like to ask you how to modify the size of the first column to adapt the text size? – user5802211 Sep 9 '17 at 10:05
  • @samcarter, thank you very much for edit! i learned something ... – Zarko Sep 9 '17 at 12:06

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.