Merging rows in LaTeX uses the multirow package
To merge rows in a LaTeX table, you need the multirow package and the \multirow command. The command stacks content vertically across multiple rows in a single column. You add \usepackage{multirow} to your document preamble, then use \multirow{number of rows}{width}{content} in the cell where you want the merged content to start.
The basic syntax looks like this: \multirow{3}{*}{Your text} merges 3 rows in that column, with the asterisk telling LaTeX to calculate the width automatically. The rows below the starting cell in that column must be left empty — you do not put anything in them, just leave the cell blank with an ampersand.
This approach works because LaTeX tables process cells left to right, top to bottom. When you declare a multirow, LaTeX reserves that vertical space and skips the cells beneath it automatically.
Key Takeaways
- Add \usepackage{multirow} at the top of your document to enable row merging.
- Use \multirow{3}{*}{text} to merge 3 rows, replacing the number with however many rows you need.
- Leave the cells directly below a multirow command empty — do not put content in them.
- The asterisk in \multirow{3}{*} tells LaTeX to calculate column width automatically; use a specific width like 2cm if you need precise control.
A working example with three merged rows
Here is a complete table that merges the first column across three rows:
\documentclass{article} \usepackage{multirow} \begin{document} \begin{tabular}{|c|c|} \hline \multirow{3}{*}{Merged} & Row 1 \\ & Row 2 \\ & Row 3 \\ \hline \end{tabular} \end{document}
The first row contains \multirow{3}{*}{Merged}, which tells LaTeX to use that cell for 3 rows vertically. The second and third rows have nothing before the ampersand — those cells are left empty because the multirow command is already occupying that space. The text "Merged" appears centered across all three rows in the first column.
If you want the merged text aligned to the top instead of centered, add [t] after the row count: \multirow{3}[t]{*}{Merged}. Use [b] for bottom alignment.
Merging columns and rows at the same time
You can combine \multirow with \multicolumn to merge both rows and columns in the same cell. Use \multicolumn first (which spans columns), then nest \multirow inside it (which spans rows).
For example, \multicolumn{2}{|c|}{\multirow{2}{*}{Merged}} merges 2 columns and 2 rows. The structure is: multicolumn on the outside, multirow on the inside. The cells you skip are those that fall within both the row span and the column span — if you merge 2 rows and 2 columns, you skip 3 additional cells (the ones to the right and below the merged cell).
Fixing alignment and spacing issues
If your merged text appears off-center or too high, the asterisk in \multirow{3}{*} may not be calculating width correctly for your content. Replace the asterisk with a specific width: \multirow{3}{2cm}{Your text} gives the cell a fixed width of 2 centimeters. Adjust the measurement up or down depending on how much space your text needs.
If rows are too close together or the merged text looks cramped, add vertical padding with \renewcommand{\arraystretch}{1.5} before your table. This multiplies the default row height by 1.5; increase the number for more space. Place this command inside the table environment or before \begin{tabular}.
For merged cells that contain multiple lines of text, use \parbox inside the multirow: \multirow{3}{2cm}{\parbox{2cm}{Line 1 \\ Line 2}}. This lets you break text across lines within the merged cell.
When multirow does not work as expected
If the merged cell appears in the wrong position or LaTeX throws an error, check that you have \usepackage{multirow} in your preamble. Without it, the \multirow command is undefined. Also verify that the number of empty cells below the multirow command matches the row count — if you say \multirow{3}{*}, you must leave the next 2 rows empty in that column.
If your table uses booktabs package rules (like \toprule, \midrule), multirow can behave unpredictably with those rules. Use standard \hline instead, or place the \hline commands carefully to avoid crossing the merged cell.
Frequently Asked Questions
Can I merge rows in multiple columns at once?
Yes, but you do it separately for each column. Each column gets its own \multirow command. If you want to merge rows 1–3 in both the first and second columns, put \multirow{3}{*}{text1} in column 1 and \multirow{3}{*}{text2} in column 2 of the first row, then leave both columns empty in rows 2 and 3.
What is the difference between multirow and multicolumn?
\multirow spans rows vertically (stacks cells down). \multicolumn spans columns horizontally (stretches cells across). You can use both in the same table on different cells, or combine them in one cell to merge both directions at once.
How do I center text in a merged cell?
By default, \multirow centers text vertically. For horizontal centering, make sure your column is defined as c (centered) in the \begin{tabular}{|c|c|} line, not l (left) or r (right). If you need different alignment just for that cell, wrap the text in \centering or use alignment options like [t] for top.
Can I merge rows in a table that uses colors or shading?
Yes, but explore colors to individual cells before using multirow, not after. Use \cellcolor{gray} from the xcolor package on the cells you want to shade, then explore multirow to the merged content. If the shading looks uneven across the merged cell, adjust the row height with \arraystretch.