Beamer:表格内容重叠

Beamer:表格内容重叠

我发现普通 latexpdf 文件中的表格显示得非常整齐,但是当我将其复制到投影仪中时,里面的数字重叠了。我尝试使用 $\scalebox$,但它不起作用。有人能帮我吗?谢谢。 在此处输入图片描述

\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}

重新编辑,我的进一步问题是,给出解决方案(第一种格式情况),如何控制第一列的大小?我根据第一种格式情况的代码进行修改,结果如下

在此处输入图片描述

我认为问题出在第一列,如果我可以修改第一列的文本,那么问题就解决了。你能进一步告诉我如何修改吗?

\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}

答案1

您的表格太大,无法放入框架的可用空间。在我看来,唯一的方法是重新设计表格:

  • 使用siunitx包对表格进行数字格式化
  • 使用较小的字体
  • 考虑使用标准符号来表示不确定性

在此处输入图片描述

\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}

编辑: 一个可能的解决方案示例,考虑下面的情况中的评论,即第一列中有较长的文本,并且您希望将其分成更多行,那么解决方案就是使用列类型p{<length>}。例如:

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

然而,经过这种改变,结果就变得不如现在那么美观了。例如,看看框架上的第二个表格,想象一下,第一列中的文本有四行 :-(

可能的解决方案是使用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}

这使:

在此处输入图片描述

相关内容