在表格的列中新增行時出錯

在表格的列中新增行時出錯

我從這裡的答案中得到了將標準表移植到施普林格日記中的一個很好的答案 乳膠桌缺少邊框線 使用以下程式碼

\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table*}[ht]
    \caption{Result}
\sisetup{table-format=2.1,
         detect-weight, % <--
         }
\begin{tblr}{hlines, vlines,
             colspec = {X[c] X[1.2,c] X[1.8,c] X[c, si]},
             cell{even}{2} = {r=2}{},
             cell{odd[3]}{Z} = {font=\bfseries},
             row{1} = {guard}
             } 
Users Set Size (USS)
    &   Range of Users Individual
        &   Index of scalar array for mapping
            &   Transfer Failure        \\
\SetCell[r=6]{c}    6
    & 6 & 10& 23                        \\
    &   & 4 & 18.3                      \\
    & 7 & 0 & 13.3                      \\
    &   & 4 & 33.3                      \\
    & 7 & 1 & 17                        \\
    &   & 2 & 66.6                      \\
\end{tblr}
   \end{table*}
\end{document}

(上面乳膠的圖像已附上),但我需要在第3 列和第4 列的每個單元格中添加一行。的一行。所以我無法理解我需要修改的地方\SetCell[r=6]{c}\SetCell[r=9]{c}但得到了奇怪的輸出和錯誤。誰能告訴我這個乳膠代碼需要修改什麼在此輸入影像描述

答案1

作為@Clara 答案的補充 (+1) ...

  • 在我的問題中使用的程式碼中,表序言具有以下含義
\begin{tblr}{hlines, vlines,
     colspec = {X[c] X[1.2,c] X[1.8,c] X[c, si]}, % determine column types
     cell{even}{2} = {r=2}{}, % determine where multi row cells, which span 
                              % two successive rows start: at each even row 
                              % after second row
   cell{odd[3]}{Z} = {font=\bfseries}, % determine in which rows numbers in 
                              % the last columns are in the boldface shape
             row{1} = {guard} % protect text in the `S` columns in the first 
                              % row, that not interfere in S column formating
             }
  • 您不提供信息,這些附加行中有哪些內容以及某些數字是否為粗體。
  • 假設預期結果類似於以下內容

在此輸入影像描述

比您需要在離子問題所示的程式碼中進行以下更改:

\begin{tblr}{hlines, vlines,
     colspec = {X[c] X[1.2,c] X[1.8,c] X[c, si]},
     cell{2,5,8}{2} = {r=3}{},           % determine multi row cells in the second column
                                         % which span three successive adjacent rows
     cell{4,7,10}{Z} = {font=\bfseries}, % determine which cells in the last column are in boldface
     row{1} = {guard}
             }
  • 有關使用的程式碼的更多詳細信息,您應該閱讀tabularray軟體包文件或詢問(在註釋中),所提供的建議中的內容您不清楚。
  • 為了完整起見,上面產生的完整 MWE 為:
\documentclass{sn-jnl}

\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table*}[ht]
    \caption{Result}
\sisetup{table-format=2.1,
         detect-weight, % <--
         }
\begin{tblr}{hlines, vlines,
     colspec = {X[c] X[1.2,c] X[1.8,c] X[c, si]},
     cell{2,5,8}{2} = {r=3}{},           % determine multi row cells in the second column
                                         % which span three successive adjacent rows
     cell{4,7,10}{Z} = {font=\bfseries}, % determine which cells in the last column are in boldface
     row{1} = {guard}
             }
Users Set Size (USS)
    &   Range of Users Individual
        &   Index of scalar array for mapping
            &   Transfer Failure        \\
\SetCell[r=9]{c}    9    % multirow cell in the first column, spanning 9 rows
    & 6 & 10& 23                        \\
    &   & 7 & 20                        \\
    &   & 4 & 18.3                      \\
    & 7 & 0 & 13.3                      \\
    &   & 0 & 13.3                      \\
    &   & 4 & 33.3                      \\
    & 7 & 1 & 17                        \\
    &   & 3 & 11                        \\
    &   & 2 & 66.6                      \\
\end{tblr}
   \end{table*}
\end{document}

答案2

我不確定這是否是您要找的。我建議將風格和內容完全分開,而不是將它們混合在一起。

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table}
\caption{Result}
\begin{tblr}
{
colspec        = {X[c,m]X[1.2,c,m]X[1.8,c,m]X[c,m,si={table-format=2.1,detect-weight}]},
cell{2}{1}     = {r=9}{},
cell{2,5,8}{2} = {r=3}{},
cell{3,6,9}{Z} = {font=\bfseries},
row{1}         = {guard},
hlines,vlines,
}
Users Set Size (USS) & Range of Users Individual & Index of scalar array for mapping & Transfer Failure \\
6                    & 6                         & 10                                & 23               \\
                     &                           & 4                                 & 18.3             \\
                     &                           & 4                                 & 18.3             \\
                     & 7                         & 0                                 & 13.3             \\
                     &                           & 4                                 & 33.3             \\
                     &                           & 4                                 & 33.3             \\
                     & 7                         & 1                                 & 17               \\
                     &                           & 2                                 & 66.6             \\
                     &                           & 2                                 & 66.6             \\
\end{tblr}
\end{table}
\end{document}

在此輸入影像描述

相關內容