已经有一段时间没有使用 Latex 了,我希望能够重现如下所示的表格。我该怎么做呢?
\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}
答案1
使用tabularray
包我们得到下表。这是你想要的吗?
\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}