如何为论文制作指定表格

如何为论文制作指定表格

我是 Latex 的新手,正在尝试解决一篇论文中的一个表格。这是我想要在 Latex 中复制的表格

在此处输入图片描述

CODE> 到目前为止,我已经成功绘制了大部分列,但仍然缺少 D 列

\documentclass[twocolumn]{article}
\usepackage{booktabs,siunitx}

\newcommand{\mc}[3]{\multicolumn{#1}{#2}{#3}}

\begin{document}

\begin{table*}
\centering
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
     c
     S[table-format=-2.4]
     S[table-format=-2.4]
     S[table-format=-2.4]
     S[table-format=-2.4]
     S[table-format=-3.4]
     S[table-format=-3.4]
     S[table-format=-3.4]
     S[table-format=-3.4]
     S[table-format=-3.4]
   }
\toprule

 n & \mc{3}{c}{Real} & \mc{3}{c}{t} & \mc{3}{c}{MM}\\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10}

 & {C} & {Def.} & {M}
 & {C} & {Def.} & {M}
 & {C} & {Def.} & {M} \\
\midrule

 1 &   0 &   0 &   NA &   0 &    0 &    0 &   0 &   0 &  0\\
 2 &   0 &   0 &   NA &   0 &    0 &    0 &   0 &   0 &  0\\
 ... & ... &  ... & ... & ... & ... & ... & ... & ... & ...\\
 11 & 2 & 0 & 5488720 & 0.02 & 0 & 64188.27 & 0.01 & 0 & 21770.90\\
 12 & 5 & 0 & 5500756 & 0.06 &  0 & 64329.02 &  0.01 &  0 & 30960.76\\
 13 & 3 & 0 & 5494021 & 0.04 & 0 &  64250.26 & 0.02 &   0 & 40139.37\\


 \bottomrule
 \end{tabular*}
 \end{table*}

 \end{document}

谢谢

答案1

您只需要在表格开头插入一列(列类型c),将S列调整format-table为列中的数字,并将非数字输入(例如 NA 和S花括号中的非数字列标题)括起来:

在此处输入图片描述

\documentclass{article}
\usepackage{geometry}

\usepackage[T1]{fontenc}
\usepackage{booktabs, multirow}
\newcommand\mc[1]{\multicolumn{3}{c}{#1}}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{xcolor}

\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}%           %
                \bfseries\color{teal}}                          %
%---------------------------------------------------------------%

\begin{document}
    \begin{table*}
    \caption{My table}
\sisetup{detect-weight, mode=text}
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
     c
     S[table-format=3.0]
     S[table-format=4.0]
     S[table-format=3.0]
     S[table-format=6.0]
     S[table-format=2.2]
     S[table-format=1.2]
     S[table-format=6.2]
     S[table-format=2.2]
     S[table-format=1.2]
     S[table-format=5.2]
   }
    \toprule
\multirow{2.4}{*}{D}
        & {\multirow{2.4}{*}{n}}
            & \mc{Real} & \mc{t} & \mc{MM}\\
    \cmidrule{3-5} \cmidrule{6-8} \cmidrule{9-11}
        &   & {C} & {Def.} & {M}
            & {C} & {Def.} & {M}
            & {C} & {Def.} & {M} \\
\midrule
02/22/2020  & 1     &   0   &   0   &   {NA}    &   0   &    0      &    0      &   0       &   0       &  0\\
02/22/2020  & 2     &   0   &   0   &   {NA}    &   0   &    0      &    0      &   0       &   0       &  0\\
02/22/2020  & 11    &   2   &   0   & 5488720   & 0.02  &   0       & 64188.27  & 0.01      & 0         & 21770.90\\
\B 02/22/2020  
            &\B 12  &\B 5   &\B 0   &\B 5500756 &\B 0.06 &\B 0      &\B 64329.02 &\B 0.01   &\B 0       &\B 30960.76\\
02/22/2020  & 13    & 3     &   0   & 5494021   & 0.04  & 0         &  64250.26 & 0.02      &   0       & 40139.37\\
...         & {...} & {...} & {...} & {...}     & {...} & {...}     & {...}     & {...}     & {...}     & {...}\\
06/30/2020  & 130   & 447   &   24  &   113124  & 5.23  &   0.28    &  13017.52 &   3.82    &   0.26    & 11 50.88  \\
 \bottomrule
\end{tabular*}
    \end{table*}
\end{document}

相关内容