How can I reproduce this table using Latex?
Tables – Steps to Reproduce a Simple Table
tables
Related Solutions
You could define a thick version of \hline
and a thick |
as new column type as I did below. Both are based on the original code, only the thickness got changed from \arrayrulewidth
to 1pt
.
\documentclass[a4paper,png]{standalone}
\usepackage{array}
\makeatletter
\newcommand{\thickhline}{%
\noalign {\ifnum 0=`}\fi \hrule height 1pt
\futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\makeatother
\begin{document}
\begin{tabular}{c"c|c|c|c|c}
$*$ & $a$ & $b$ & $c$ & $d$ & $e$ \\\thickhline
$a$ & $a$ & $b$ & $c$ & $b$ & $d$ \\\hline
$b$ & $b$ & $c$ & $a$ & $e$ & $c$ \\\hline
$c$ & $c$ & $a$ & $b$ & $b$ & $a$ \\\hline
$d$ & $b$ & $e$ & $b$ & $e$ & $d$ \\\hline
$e$ & $d$ & $b$ & $a$ & $d$ & $c$
\end{tabular}
\end{document}
On request here a definition of a thick version of \cline
:
\newcommand{\thickcline}[1]{%
\@thickcline #1\@nil%
}
\def\@thickcline#1-#2\@nil{%
\omit
\@multicnt#1%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\advance\@multicnt-#1%
\advance\@multispan\@ne
\leaders\hrule\@height1pt\hfill
\cr
\noalign{\vskip-1pt}%
}
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}
Best Answer
The idea is to use a combination of \multicolumn command (to add vertical lines in the table) together with the \cline command (to add horizontal lines):
The code produces the following table:
This Overleaf link is extremely useful when dealing with LaTex table formatting: https://www.overleaf.com/learn/latex/Tables