3

I have the following table:

\begin{tblr}{
    colspec={X[l,1]*{9}{X[-0.6]}},
    column{1}={cmd=\bfseries},
    rowspec={*{6}{m{3em}}},
    row{1}={cmd=\bfseries},
    hlines,
    vlines={1,2,3,4,5,6}{solid},
}
    & \SetCell[c=3]{c} SRC && \SetCell[c=3]{c} MSRC && \SetCell[c=3]{c} NFRC & \\
    & RF1 & RF2 & ROI & RF1 & RF2 & ROI & RF1 & RF2 & ROI \\
    SVM & 0.54 & 0.59 & 0.6 & 0.629 & 0.354 & 0.513 & 0.42 & 0.634 & 0.374 \\
    DT & 0.418 & 0.433 & 0 .533 & 0.486 & 0.524 & 0.379 & 0.521 & 0.685 & 0.561 \\
    kNN & 0.387 & 0.536 & 0.498 & 0.536 & 0.579 & 0.453 & 0.652 & 0.626 & 0.652  \\
    GNB & 0.472 & 0.437 & 0.434 & 0.609 & 0.557 & 0.248 & 0.484 & 0.416 & 0.444 \\
\end{tblr}
\captionsetup{justification=centering}
\captionof{table}{my table test}
\label{table:myTable}

I get the following: enter image description here

I simply want the other row titles (MSRC & NFRC) to appear where they belong. However, for some reason, the SRC takes over the row completely.

1
  • 3
    you need three ambersands after the setcell: \SetCell[c=3]{c} SRC &&& as you are spanning three cells. Commented Feb 24, 2023 at 17:19

1 Answer 1

2

Like this:

enter image description here

In MWE is considered @Ulrice comment. IN this tabularray differ from other table packages, where at multi column cells should be omitted ampersands, here must be present. Beside this is changed (simplified and correct set) tblr preamble:

 \documentclass{article}
 \usepackage{caption}
 \usepackage{tabularray}
 
 \begin{document}
 \noindent%
 \begin{tblr}{hlines, vlines,
              colspec = {Q[l, font=\bfseries] *{9}{X[c]} },
              rows    = {m, ht=3em},
              row{1}  = {font=\bfseries},
              }
 \SetCell[r=2]{c}
    &   \SetCell[c=3]{c} SRC 
        &   &   &   \SetCell[c=3]{c} MSRC 
                    &   &   &   \SetCell[c=3]{c} NFRC 
                                &   &                                       \\
    & RF1   & RF2   & ROI   & RF1   & RF2   & ROI   & RF1   & RF2   & ROI   \\
SVM & 0.54  & 0.59  & 0.6   & 0.629 & 0.354 & 0.513 & 0.42  & 0.634 & 0.374 \\
DT  & 0.418 & 0.433 & 0.533 & 0.486 & 0.524 & 0.379 & 0.521 & 0.685 & 0.561 \\
kNN & 0.387 & 0.536 & 0.498 & 0.536 & 0.579 & 0.453 & 0.652 & 0.626 & 0.652 \\
GNB & 0.472 & 0.437 & 0.434 & 0.609 & 0.557 & 0.248 & 0.484 & 0.416 & 0.444 \\
\end{tblr}
\captionsetup{justification=centering}
\captionof{table}{my table test}
\label{table:myTable}
\end{document}
2
  • Thanks for the answer! Can you tell me, how can I only have 2 vertical lines separating the SRC, MSRC and NFRC ? Commented Feb 24, 2023 at 19:15
  • @syriancoffee, replace vlines with vline{5,8}={solid}, however, resulted table will become strange ,,,
    – Zarko
    Commented Feb 24, 2023 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .