Tables – How to Draw a Table in LaTeX Similar to the Given Example

tables

It has been a while without using Latex, my wish is to reproduce a table like the one attached below. How can I make it?

    \begin{document}
    \begin{table}
    \capthe tion{Resource analysis for proposed compiler.}
      \begin{tabular}{lSSSSSS}
        \toprule
        \multirow{2}{*}{n-qubits} &
          \multicolumn{2}{c}{Total gates} &
          \multicolumn{2}{c}{Depth steps} \\
          & {State Generation} & {QFT} & {StateGeneration} & {QFT} &  \\
          \midrule
        2 & 7 & 11 & 5 & 9 \\
        4 & 13 & 42 & 7 & 25 \\
        6 & 19 & 93 & 9 & 41 \\
        \bottomrule
      \end{tabular}
    \end{table}

\end{document}

This code gives the following table
enter image description here

What I want is to reproduce this one
enter image description here

Best Answer

Using tabularray package we get the following table. Is that you want?

\documentclass[12pt]{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage[justification=centering,singlelinecheck=no]{caption}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\begin{document}
    \begin{table}
        \centering\caption{Resource analysis for proposed compiler.}
        \begin{tblr}{colspec={Q[l]Q[c]Q[c]Q[c]Q[c]Q[c]},rows={m,0.8cm},cell{1}{1}={r=2,c=1}{l},hline{2}={3}{solid,rightpos=-1}}
            \toprule
            n-qubits & Total gates &  & Depth steps &  \\
            \cmidrule[l=-1]{2,3} \cmidrule[lr=-1]{4}
            & {State Generation} & {QFT} & {StateGeneration} & {QFT}  \\
            \midrule
            2 & 7 & 11 & 5 & 9 \\
            4 & 13 & 42 & 7 & 25 \\
            6 & 19 & 93 & 9 & 41 \\
            \bottomrule
        \end{tblr}
    \end{table}
\end{document}

output

Related Question