0

I got a good answer for porting the standard table into a springer journal from answer here Latex Table Missing Border Lines using following code

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

(image attached for above latex) but I need to add a row in each cell of columns 3 and 4. For example a row below 4 & 18.3, a row below 4 & 33.3 and a row below 2 & 66.6. so I am unable to understand where I need to modify I changed \SetCell[r=6]{c} to \SetCell[r=9]{c} but got strange output and error. Can anyone tell what I need to modify in this latex codeenter image description here

  • If you use my solution, it will be nice to accept it first (by clicking on the check mark at top left side of answer) ... As I see, so far you not accept any from received answers. Are no one of them solve your problem? – Zarko Mar 05 '23 at 07:13
  • @Zarko I'm curious why this question was raised. I can't think of any reason why the asker would be confused. – Clara Mar 05 '23 at 07:18
  • @Clara, probably you mean my comment above. What is confusing in it? I I just note, that it will be nice, that code used in this question (as is mentioned in question) should be accepted. And just remark, that (s)he didn't do this to any of received answer. – Zarko Mar 05 '23 at 07:47
  • @Zarko Sorry, what I mentioned is user3696623, not you. With the code snippet above, it is indeed confusing why someone would ask how to add a line. I'm not sure why the asker is having trouble understanding this. – Clara Mar 05 '23 at 07:54
  • @Clara, ok. Sorry, I misunderstood you. – Zarko Mar 05 '23 at 08:25
  • @Zarko I have accepted your answer for my previous post plz check , actually, i had just clicked on 'this answer useful button', I thought it means accepted. I am sorry. Its checked now. – user3696623 Mar 05 '23 at 18:23

2 Answers2

2

As complement to @Clara answer (+1) ...

  • In my code, which you use in your question, the table preamble has the following meaning
\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
             }
  • You not provide information, what are in those additional rows and if some numbers are in boldface.
  • Assuming, that expecting result is similar to the following

enter image description here

than you need to make the following changes in code shown ion question:

\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}
             }
  • For more details, about used code, you should read tabularray packages documentation or ask (in comments), what in provided suggestions is not clear to you.
  • For sake of completeness, the complete MWE, which generate above showed table, is:
\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}

Zarko
  • 296,517
1

I'm not sure if this is what you're looking for. I suggest separating the style and content completely instead of mixing them together.

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

enter image description here

Clara
  • 6,012