Sanchit Jain
Sanchit Jain

Reputation: 115

How to merge cells of row in table in latex?

enter image description here enter image description here For example i have this table from excel which i want to add in latex. I am trying but ot able to sucesfully manage to do this. any lead to this will great help to me.

I tried using multirow in latex but actually did not work.

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
  \hline
  \multicolumn{2}{|c|}{}       & \multicolumn{3}{c|} {\textbf{97\%}}& \multicolumn{3}{c|} {\textbf{146\%}}& \multicolumn{3}{c|} {\textbf{244\%}}\\
  \cline{3-5}
  \multicolumn{2}{|c|}{}                      & Latency       & Channel Utilisation       & Bandwidth Utilisation & Latency       & Channel Utilisation       & Bandwidth Utilisation & Latency       & Channel Utilisation       & Bandwidth Utilisation\\
  \hline
  CCTV Display & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  CCTV Recorder & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  VCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  BCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  TCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  PECU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  OBCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 1  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 2  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 3  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 4  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 5  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  Switch 6  & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0& 0    & 0 \\
  \hline
\end{tabular}

Upvotes: -1

Views: 652

Answers (1)

For a professional looking table, I suggest the following layout:

\documentclass{article}

\usepackage[hmargin=1cm]{geometry}
\usepackage{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}

\begin{table}[htbp]
\caption{some caption text}
\begin{tblr}{
  cells={halign=c,valign=m}, 
  colspec={@{}X[1.3,halign=l]XXXXXXXXX@{}},
  colsep={3pt}
}
  \toprule
  Increase in Data Volume & \SetCell[c=3]{} 97\% &&& \SetCell[c=3]{} 146\% &&& \SetCell[c=3]{} 244\% &&\\
  \cmidrule[r]{2-4}\cmidrule[lr]{5-7}\cmidrule[l]{8-10}
  Parameter & Latency       & Channel Utilisation       & Bandwidth Utilisation & Latency       & Channel Utilisation       & Bandwidth Utilisation & Latency       & Channel Utilisation       & Bandwidth Utilisation\\
  \midrule
  CCTV Display & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  CCTV Recorder & 0    & 0    & 0    & 0& 0    & 0   & 0& 0    & 0 \\
  VCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0    & 0 \\
  BCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0    & 0 \\
  TCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0    & 0 \\
  PECU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0    & 0 \\
  OBCU & 0    & 0    & 0    & 0& 0    & 0    & 0    & 0    & 0 \\
  Switch 1  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  Switch 2  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  Switch 3  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  Switch 4  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  Switch 5  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  Switch 6  & 0    & 0    & 0    & 0& 0    & 0    & 0& 0    & 0 \\
  \bottomrule
\end{tblr}
\end{table}

\end{document}

enter image description here

Upvotes: 1

Related Questions