latex 表格方程式不起作用

latex 表格方程式不起作用

我想制作一张这样的桌子在此处输入图片描述

然而我只能得到在此处输入图片描述

这是我的代码。

\documentclass{beamer}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{frame}
  \frametitle{Simulation example }

  \begin{table}\footnotesize
    \centering
    \caption{Performance of five methods at penalty levels $\lambda_j=\{2^{j-1}(logp)/n\}^{1/2}$ $(j=1,2,3)$, across 100 replications.}
    \label{tab:fancy_table}
    \renewcommand{\arraystretch}{0.8}
    \setlength{\tabcolsep}{4mm}
      \begin{tabular}{l
        c
        S[separate-uncertainty,table-figures-uncertainty=1]
        S[separate-uncertainty,table-figures-uncertainty=1]
        S
        S}
        \toprule
        {Method} &             & {$\hat{\sigma}/\sigma$} & {$\bar{\sigma}/\sigma$} & {AMS} & {SSP} \\ 
        \midrule
                 & $\lambda_1$ & 1.6 \pm 0.5             & -1.1 \pm 0.6            & 7.6   & 1     \\    
        PMLE     & $\lambda_1$ & 2.6 \pm 0.5             & -0.2 \pm 0.5            & 3     & 1     \\ 
                 & $\lambda_1$ & 3.7 \pm 0.6             & 1.1 \pm 1.2             & 1.9   & 0.3   \\ 
        \midrule
                 & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\   
        BC       & $\lambda_1$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\ 
                 & $\lambda_1$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\ 
        \midrule
        Scaled   & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
        lasso    & $\lambda_1$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\     
                 & $\lambda_1$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\ 
        \midrule
        Scaled   & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
        MCP      & $\lambda_1$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\   
                 & $\lambda_1$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\
        \midrule
        Scaled   & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
        SCAD     & $\lambda_1$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\     
                 & $\lambda_1$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\
        \bottomrule
      \end{tabular}
  \end{table}
\end{frame}

\end{document}

答案1

我不太清楚你想要什么。是自动添加.0整数还是使用空格代替规则或居中点作为小数点?

\documentclass{beamer}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-decimal-marker={\cdot}}
\begin{document}

\begin{frame}{Simulation example }

  \begin{table}
    \footnotesize
    \centering
    \caption{Performance of five methods at penalty levels $\lambda_j=\{2^{j-1}(logp)/n\}^{1/2}$ ($j=1,2,3$), across 100 replications.}
    \label{tab:fancy_table}
    \renewcommand{\arraystretch}{0.8}
    \setlength{\tabcolsep}{4mm}
    \begin{tabular}{
      @{}
      l
      c
      S[table-format=-1.1+-1.1,separate-uncertainty,table-figures-uncertainty=1]
      S[table-format=-1.1+-1.1,separate-uncertainty,table-figures-uncertainty=1]
      S[table-format=2.1,round-integer-to-decimal,round-mode=places,round-precision=1]
      S[table-format=1.1,round-integer-to-decimal,round-mode=places,round-precision=1]
      @{}
      }
      Method &             & {$\hat{\sigma}/\sigma$} & {$\bar{\sigma}/\sigma$} & {AMS} & {SSP} \\ 
      \addlinespace
             & $\lambda_1$ & 1.6 \pm 0.5             & -1.1 \pm 0.6            & 7.6   & 1     \\    
      PMLE   & $\lambda_2$ & 2.6 \pm 0.5             & -0.2 \pm 0.5            & 3     & 1     \\ 
             & $\lambda_3$ & 3.7 \pm 0.6             & 1.1 \pm 1.2             & 1.9   & 0.3   \\ 
      \addlinespace
             & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\   
      BC     & $\lambda_2$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\ 
             & $\lambda_3$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\ 
      \addlinespace
      Scaled & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
      lasso  & $\lambda_2$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\     
             & $\lambda_3$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\ 
      \addlinespace
      Scaled & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
      MCP    & $\lambda_2$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\   
             & $\lambda_3$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\
      \addlinespace
      Scaled & $\lambda_1$ & -0.1 \pm 0.6            & -2.2 \pm 0.7            & 15.3  & 1     \\     
      SCAD   & $\lambda_2$ & 1.3 \pm 0.6             & -0.2 \pm 0.5            & 3.2   & 1     \\     
             & $\lambda_3$ & 3.1 \pm 0.7             & 0.9 \pm 1.2             & 2.1   & 0.4   \\
    \end{tabular}
  \end{table}
\end{frame}

\end{document}

在此处输入图片描述

答案2

作为对 nice 的补充亨利·孟克答案。主要区别在于所使用的不确定性语法和所使用的表环境。

\documentclass{beamer}
\setbeamerfont{caption}{size=\footnotesize}

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{frame}{Simulation example}
    \begin{table}
    \small
    \centering
\caption{Performance of five methods at penalty levels $\lambda_j=\{2^{j-1}\log_p/n\}^{1/2}$ ($j=1,2,3$), across 100 replications.}
\label{tab:fancy_table}
    \renewcommand{\arraystretch}{0.8}
    \setlength\aboverulesep{1pt}
    \setlength\belowrulesep{2pt}
    \sisetup{table-format=-1.1(1),
             separate-uncertainty,
             round-integer-to-decimal,
             round-mode=places,
             round-precision=1}
\begin{tabular*}{0.9\linewidth}{l
                                @{\extracolsep{\fill}}
                                >{$}c<{$}
                                *{2}{S}
                                S[table-format=2.1]
                                S[table-format=1.1]
                                }
  \toprule
  Method &           & {$\hat{\sigma}/\sigma$} & {$\bar{\sigma}/\sigma$} & {AMS} & {SSP} \\
  \midrule
         & \lambda_1 &  1.6(5)  & -1.1(6)       &  7.6  & 1     \\
  PMLE   & \lambda_2 &  2.6(5)  & -0.2(5)       &  3    & 1     \\
         & \lambda_3 &  3.7(6)  &  1.1(12)      &  1.9  & 0.3   \\
  \midrule
         & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  BC     & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \midrule
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  lasso  & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \midrule
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  MCP    & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \midrule
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  SCAD   & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \bottomrule
\end{tabular*}
    \end{table}
\end{frame}

\end{document}

在此处输入图片描述

如果您不喜欢在表格中设置规则,请将其替换\midruleaddlinespace,删除toprule\bottomrule,并设置上方/下方的空间midrule

    \begin{table}
    \small
    \centering
\caption{Performance of five methods at penalty levels $\lambda_j=\{2^{j-1}\log_p/n\}^{1/2}$ ($j=1,2,3$), across 100 replications.}
\label{tab:fancy_table}
    \renewcommand{\arraystretch}{0.8}
    \sisetup{table-format=-1.1(1),
             separate-uncertainty,
             round-integer-to-decimal,
             round-mode=places,
             round-precision=1}
\begin{tabular*}{0.9\linewidth}{l
                                @{\extracolsep{\fill}}
                                >{$}c<{$}
                                *{2}{S}
                                S[table-format=2.1]
                                S[table-format=1.1]
                                }
  Method &           & {$\hat{\sigma}/\sigma$} 
                                & {$\bar{\sigma}/\sigma$}
                                                & {AMS} & {SSP} \\
  \addlinespace[3pt]
         & \lambda_1 &  1.6(5)  & -1.1(6)       &  7.6  & 1     \\
  PMLE   & \lambda_2 &  2.6(5)  & -0.2(5)       &  3    & 1     \\
         & \lambda_3 &  3.7(6)  &  1.1(12)      &  1.9  & 0.3   \\
  \addlinespace[3pt]
         & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  BC     & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \addlinespace[3pt]
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  lasso  & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \addlinespace[3pt]
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  MCP    & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
  \addlinespace[3pt]
  Scaled & \lambda_1 & -0.1(6)  & -2.2(7)       & 15.3  & 1     \\
  SCAD   & \lambda_2 &  1.3(6)  & -0.2(5)       &  3.2  & 1     \\
         & \lambda_3 &  3.1(7)  &  0.9(12)      &  2.1  & 0.4   \\
\end{tabular*}
    \end{table}

在此处输入图片描述

相关内容