Dear friends: I have a special table to typeset in LaTeX for a journal paper, where some columns and rows are merged.. It is a simple table only and it can be easily done in MS-Word but I don't know how to do it in LaTeX. Kindly help me with the enclosed image (table). Thanks a lot
2 Answers
Just for fun, the same table composed by tabularray
. The first version v1
as your version and the second version v2
with a more professional composition.
\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{table}
\caption{Comparative analysis of Methods 1, 2 and 3 (v1)}
\centering
\begin{tblr}{
colspec={|c|c|c|c|},
row{1-2}={font=\bfseries},
}
\midrule
\SetCell[r=2]{c} Parameters & \SetCell[c=2]{c} Existing Methods & & Proposed Method \\
\midrule
& Method 1 & Method 2 & Method 3 \\
\midrule
A & A1 & A2 & A3 \\
\midrule
B & B1 & B2 & B3 \\
\midrule
\end{tblr}
\end{table}
\begin{table}
\caption{Comparative analysis of Methods 1, 2 and 3 (v2)}
\centering
\begin{tblr}{
colspec={cccc},
row{1-2}={font=\bfseries},
}
\SetCell[r=2]{c} Parameters & \SetCell[c=2]{c} Existing Methods & & Proposed Method \\
\cmidrule[lr]{2-3} \cmidrule[lr]{4}
& Method 1 & Method 2 & Method 3 \\
\midrule
A & A1 & A2 & A3 \\
B & B1 & B2 & B3 \\
\end{tblr}
\end{table}
\end{document}
Thanks to the comment by leandriis, I tried to create a typesetting in LaTeX and the output is satisfactory.. I share my input file below..
\documentclass[12pt]{report}
\usepackage{multirow}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\multirow{2}{*}{\textbf{Parameters}} & \multicolumn{2}{ c| }{\textbf{Existing Methods}}& \textbf{Proposed Method} \\
\cline{2-4}
& \textbf{Method 1} & \textbf{Method 2} & \textbf{Method 3} \\ \hline
A & A1 & A2 & A3 \\ \hline
B & B1 & B2 & B3 \\ \hline
\end{tabular}
\caption{Comparative analysis of Methods 1, 2 and 3}
\end{table}
\end{document}
-
1Good, that you figured it out by yourself! One remark,
\label
should be\caption
– marvMar 20, 2022 at 10:27 -
Dear marv, thanks for the kind correction. I corrected my latex program as this may be useful for the newcomers here. Mar 20, 2022 at 11:40
\multicolumn
(See also: How to merge columns in a table?) and to merge cells across rows, you can use\multirow
from themultirow
package (See also: How to merge cells vertically).