0

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

1

1 Answer 1

2

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

5
  • Thank you for your possible solution on this, I want to ask about the midline that separates Total gates and the State generation. How can I adjust so that it can reach the column with QFT Commented Jan 4, 2023 at 1:25
  • @Kimwaga makono. As it is it just reach the column of QFT if you draw all hlines and vlines you can see it. You just want it a little bigger but not crossing the column of QFT or want it to join with the other line separates Debth Steps and State generation? Both can be done.
    – miltos
    Commented Jan 4, 2023 at 6:53
  • It should start at S for State generation to T for QFT Commented Jan 7, 2023 at 4:31
  • @Kimwaga makono: I modified the code the way to help you achieve what you want. Please check it out and the new output. Do you need this for the next two columns also?
    – miltos
    Commented Jan 7, 2023 at 7:30
  • 1
    Thank you for your help, I just edited \cmidrule[lr=-1]{4} to \cmidrule[lr=-1]{4,5} Commented Jan 11, 2023 at 12:38

You must log in to answer this question.

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