How to Merge Cells in LaTeX Tables (multirow, multicolumn)
Complex data often requires cells that span multiple columns or rows. LaTeX provides \multicolumn for horizontal merging and the multirow package for vertical merging. Combining them lets you build sophisticated table layouts for any academic paper. Bibby AI renders these complex tables instantly in its live preview, so you can adjust spans and alignment without waiting for slow compiles.
Merge Cells Horizontally with multicolumn
Use \multicolumn{num_cols}{alignment}{content} to span a cell across multiple columns. This is built into LaTeX — no extra package needed:
\begin{table}[htbp]
\centering
\caption{Quarterly Revenue by Region}
\begin{tabular}{|l|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{\textbf{2024 Revenue Report (in \$M)}} \\
\hline
\textbf{Region} & \textbf{Q1} & \textbf{Q2} & \textbf{Q3} & \textbf{Q4} \\
\hline
North America & 12.5 & 14.2 & 13.8 & 16.1 \\
Europe & 8.3 & 9.1 & 8.7 & 10.4 \\
Asia Pacific & 6.7 & 7.8 & 9.2 & 11.3 \\
\hline
\multicolumn{1}{|l|}{\textbf{Total}} & \multicolumn{4}{c|}{\textbf{127.1}} \\
\hline
\end{tabular}
\end{table}Merge Cells Vertically with multirow
Load the multirow package and use \multirow{num_rows}{width}{content}. Use * for automatic width. Leave the corresponding cells in subsequent rows empty:
\usepackage{multirow}
\begin{table}[htbp]
\centering
\caption{Experiment Results}
\begin{tabular}{|l|l|c|c|}
\hline
\textbf{Category} & \textbf{Method} & \textbf{Precision} & \textbf{Recall} \\
\hline
\multirow{3}{*}{Supervised} & SVM & 0.89 & 0.85 \\
& Random Forest & 0.91 & 0.87 \\
& Neural Net & 0.94 & 0.92 \\
\hline
\multirow{2}{*}{Unsupervised} & K-Means & 0.72 & 0.68 \\
& DBSCAN & 0.76 & 0.71 \\
\hline
\end{tabular}
\end{table}Combine multirow and multicolumn
To merge a block of cells both horizontally and vertically, nest \multirow inside \multicolumn. The \multicolumn goes on the first row, and subsequent rows use \multicolumn with empty content:
\usepackage{multirow}
\begin{table}[htbp]
\centering
\caption{System Performance Comparison}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{\textbf{System}}} & \multicolumn{2}{c|}{\textbf{Metrics}} \\
\multicolumn{2}{|c|}{} & \textbf{Speed} & \textbf{Accuracy} \\
\hline
\multirow{2}{*}{Model A} & Train & 2.3s & 95.1\% \\
& Test & 0.1s & 93.8\% \\
\hline
\multirow{2}{*}{Model B} & Train & 5.1s & 97.2\% \\
& Test & 0.3s & 96.5\% \\
\hline
\end{tabular}
\end{table}💡 Tips
- •When using \multirow, leave the merged cells in subsequent rows empty but keep the & column separators.
- •Use \cline{start-end} instead of \hline to draw partial horizontal lines that respect merged cells: e.g., \cline{2-4}.
- •The * width argument in \multirow{3}{*}{text} auto-calculates width — use a fixed width like {2cm} only if you need text wrapping.
- •Bibby AI highlights table syntax errors in real time, making it much easier to debug complex merged-cell layouts.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free