Quantcast
Channel: How to make a table with multiple columns having different number of elements under different rows? - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 4

How to make a table with multiple columns having different number of elements under different rows?

$
0
0

I tried using the following code, with an unexpected outcome shown below (I've also attached the outcome I am expecting):

\documentclass{article}\usepackage{siunitx}\usepackage{array,booktabs}\begin{document}\begin{table}    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lSS@{}} \\\toprule&{\textit{Score}}\\\midrule        \textbf{class 1}  & 0 \\        \midrule&\multicolumn{2}{cc}{\textbf{Model A}\textbf{Model B}}\\        \midrule        \textbf{class A}   0  &  0\\         \textbf{class B}  0  &  0\\        \textbf{class C}  0  &  0\\        \textbf{class D}  0  &  0\\        \midrule        \textbf{class X}  0  &  0\\        \textbf{class Y}  0  &  0\\        \textbf{class Z}  0  &  0\\        \bottomrule    \end{tabular*}    \caption{caption here}    \label{table:results}\end{table}\end{document}

This has three major issues shown below: (1) the alignment of "Score" should be centered, (2) Model A Model B are repeating, and (3) the 0 values are shifted towards the left

enter image description here

I am trying to get an output which looks like:

enter image description here


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>