我需要在 LATEX 中为该表添加代码

我需要在 LATEX 中为该表添加代码

在此处输入图片描述

我需要这个表格的 latex 格式的代码,请帮帮我。我已经学习了相同的行和列代码,但是这个更复杂

答案1

使用@User23456234 答案(+1)作为起点:

\documentclass{article}
\usepackage{bm}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table}[ht]
    \centering
\begin{tblr}{hlines, vlines,
             colspec = {S[table-format=1.1]
                        *{9}{S[table-format=1.34]}},
             row{1-4,Z} = {guard, c},
             row{2,3}   = {mode=math},
             cell{2,3}{2,5,8} = {c=3}{mode=math},    % <--
            }
\SetCell[r=4]{c}    Y
    &   \SetCell[c=9]{c, font=\bfseries}   Dimensionless Concentration of the VOC  $\bm{U(X)}$
        && &&& &&&      \\
    &   \alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1
        &&& \alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1
                    &&& \alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1
                        &&                  \\
    &   \alpha_2=1
        &&& \alpha_2=10 
                    &&& \alpha_2=30 
                        &&                  \\
    & Num.  & MADM  & Error 
        & Num.  & MADM  & Error
            & Num.  & MADM  & Error         \\
0   & 1 & 1 & 0.0000    & 1 & 1 & 0.0000    & 1 & 1 & 0.0000    \\
0.2
    & 0.9922 & 0.9922 & 0.0100 
        & 0.9985 & 0.9985 & 0.0000
            & 0.9994 & 0.9994 & 0.0000          \\
0.4 & 0.9862 & 0.9862 &0.0101
        & 0.9973 & 0.9973 & 0.0000
            & 0.9990 & 0.9990 & 0.0000          \\
0.6 & 0.9819 & 0.9820 & 0.0203
        & 0.9964 & 0.9965 & 0.0100
            & 0.9987 & 0.9987 & 0.0000          \\
0.8 & 0.9794 & 0.9794 & 0.0102
        & 0.9960 & 0.9960 & 0.0100
            & 0.9985 & 0.9985 & 0.0000          \\
1.0
    &0.9785&0.9785&0.0204
        & 0.9957 & 0.9959 & 0.0200
            & 0.9985 & 0.9985 &0.0000           \\
    &   \SetCell[c=2]{l} Average \% Error     
        &   & 0.0118 
                &   \SetCell[c=2]{l} Average \% Error 
                    &   &   0.0066 
                            & \SetCell[c=2]{l} Average \%  Error 
                                &   &   0.0000  \\
\end{tblr}
    \end{table}
\end{document}

在此处输入图片描述

或者使用`booktabs:

\documentclass{article}
\usepackage{bm}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
    \begin{table}[ht]
    \centering
\begin{tblr}{colspec = {S[table-format=1.1]
                        *{9}{S[table-format=1.4]}},
             row{1-4,Z} = {guard, c},
             row{2,3}   = {mode=math},
             cell{2,3}{2,5,8} = {c=3}{mode=math},    % <--
            }
    \toprule
\SetCell[r=4]{c}    Y
    &   \SetCell[c=9]{c, font=\bfseries}   Dimensionless Concentration of the VOC  $\bm{U(X)}$
        && &&& &&&      \\
    &  \SetCell[c=9]{c, font=\bfseries}   \alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1
        && &&& &&&      \\
    \midrule
    &   \alpha_2=1
        &&& \alpha_2=10 
                    &&& \alpha_2=30 
                        &&                  \\
    \cmidrule{2-10}
    \cmidrule[r]{2-4}
    \cmidrule[r]{5-7}
    \cmidrule[r]{8-10}
    & Num.  & MADM  & Error 
        & Num.  & MADM  & Error
            & Num.  & MADM  & Error         \\
    \midrule
0   & 1 & 1 & 0.0000    & 1 & 1 & 0.0000    & 1 & 1 & 0.0000    \\
0.2
    & 0.9922 & 0.9922 & 0.0100 
        & 0.9985 & 0.9985 & 0.0000
            & 0.9994 & 0.9994 & 0.0000          \\
0.4 & 0.9862 & 0.9862 &0.0101
        & 0.9973 & 0.9973 & 0.0000
            & 0.9990 & 0.9990 & 0.0000          \\
0.6 & 0.9819 & 0.9820 & 0.0203
        & 0.9964 & 0.9965 & 0.0100
            & 0.9987 & 0.9987 & 0.0000          \\
0.8 & 0.9794 & 0.9794 & 0.0102
        & 0.9960 & 0.9960 & 0.0100
            & 0.9985 & 0.9985 & 0.0000          \\
1.0
    &0.9785&0.9785&0.0204
        & 0.9957 & 0.9959 & 0.0200
            & 0.9985 & 0.9985 &0.0000           \\
    \cmidrule{2-10}
    \cmidrule[r]{2-4}
    \cmidrule[r]{5-7}
    \cmidrule[r]{8-10}
    &   \SetCell[c=2]{l} Average \% Error     
        &   & 0.0118 
                &   \SetCell[c=2]{l} Average \% Error 
                    &   &   0.0066 
                            & \SetCell[c=2]{l} Average \%  Error 
                                &   &   0.0000  \\
    \bottomrule
\end{tblr}
    \end{table}
\end{document}

在此处输入图片描述

答案2

我会避免使用垂直规则:表格不是电子表格。

第一行最好是表格的标题,而不是表格的一部分。

\documentclass{article}
\usepackage{newtxtext,newtxmath}
\usepackage{caption,booktabs,siunitx}

\begin{document}

\begin{table}
\centering
%\small

\caption{Dimensionless concentration of the VOC $U(X)$}

\setlength{\tabcolsep}{0pt} % let TeX compute
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  S[table-format=1.1]
  *{9}{S[table-format=1.4]}
  @{}
}
\toprule
Y & \multicolumn{9}{c}{$\alpha_1=\alpha_3=\alpha_4=\alpha_5=\num{0.1}$} \\
\cmidrule{2-10}
  & \multicolumn{3}{c}{$\alpha_2=1$}
  & \multicolumn{3}{c}{$\alpha_2=10$}
  & \multicolumn{3}{c}{$\alpha_2=30$} \\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10}
& {Num.} & {MADM} & {Error}
& {Num.} & {MADM} & {Error}
& {Num.} & {MADM} & {Error} \\
\midrule
0   & 1      & 1      & 0.0000 & 1      & 1      & 0.0000 & 1      & 1      & 0.0000 \\
0.2 & 0.9922 & 0.9922 & 0.0100 & 0.9985 & 0.9985 & 0.0000 & 0.9994 & 0.9994 & 0.0000 \\
%[other rows]
1   & 0.9785 & 0.9785 & 0.0204 & 0.9957 & 0.9959 & 0.0200 & 0.9985 & 0.9985 & 0.0000 \\
\midrule
& \multicolumn{2}{l}{Average error \%} & 0.0118
& \multicolumn{2}{l}{Average error \%} & 0.0066
& \multicolumn{2}{l}{Average error \%} & 0.0000 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

答案3

我提供了一张类似于您帖子中所示的表格。我删除了垂直规则,因为它们几乎总是会降低其可读性。(请参阅 booktabs 包文档:https://mirror.mwt.me/ctan/macros/latex/contrib/booktabs/booktabs.pdf)我还做了一些其他更改以提高可读性,例如在行之间添加更多间隙。我认为您也可以删除第二行,因为您重复了两次相同的内容。

\documentclass{article}
\usepackage{stix2}
\usepackage[margin=1in]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
%11,10
\begin{booktabs}{
    cells=c
    ,cell{4-Z}{-}={l}
}
\toprule
&\SetCell[c=9]{c} \textbf{Dimensionless Concentration of the VOC} $\mathbf{U(X)}$
    && &&& &&&
\\
\cmidrule[lr]{2-4}\cmidrule[lr]{5-7}\cmidrule[lr]{8-10}
&
    \SetCell[c=3]{c} $\alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1$ &&&
        \SetCell[c=3]{c} $\alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1$ &&&
            \SetCell[c=3]{c} $\alpha_1=\alpha_3=\alpha_4=\alpha_5=0.1$ &&&
\\
\cmidrule[lr]{2-4}\cmidrule[lr]{5-7}\cmidrule[lr]{8-10}
&
    \SetCell[c=3]{c} $\alpha_2=1$ &&&
        \SetCell[c=3]{c} $\alpha_2=10$ &&&
            \SetCell[c=3]{c} $\alpha_2=30$ &&&
\\
\cmidrule[lr]{2-4}\cmidrule[lr]{5-7}\cmidrule[lr]{8-10}
Y
    &\#{}&MADM&Error
        &\#{}&MADM&Error
            &\#{}&MADM&Error
\\
\midrule
0.0
    &1.0000&1.0000&0.0000
        &1.0000&1.0000&0.0000
            &1.0000&1.0000&0.0000
\\
0.2 
    &0.9922&0.9922&0.0100
        &0.9985&0.9985&0.0000
            &0.9994&0.9994&0.0000
\\
0.4
    &0.9862&0.9862&0.0101
        &0.9973&0.9973&0.0000
            &0.9990&0.9990&0.0000
\\
0.6
    &0.9819&0.9820&0.0203
        &0.9964&0.9965&0.0100
            &0.9987&0.9987&0.0000
\\
0.8
    &0.9794&0.9794&0.0102
        &0.9960&0.9960&0.0100
            &0.9985&0.9985&0.0000
\\
1.0
    &0.9785&0.9785&0.0204
        &0.9957&0.9959&0.0200
            &0.9985&0.9985&0.0000
\\
\midrule
&\SetCell[c=2]{l} Average \%{} Error && 0.0118 &
    \SetCell[c=2]{l} Average \%{} Error && 0.0066 &
        \SetCell[c=2]{l} Average \%{} Error && 0.0000
\\
\bottomrule
\end{booktabs}
\end{document}

在此处输入图片描述

相关内容