Merge cells across rows and columns in LaTeX tables.
To span multiple columns use \multicolumn and to span multiple rows load the multirow package and use \multirow. Combining both requires nesting the multirow command inside a multicolumn declaration.
The short answer: use \multicolumn{cols}{align}{text} for horizontal merges, \usepackage{multirow} with \multirow{rows}{width}{text} for vertical merges, and nest \multirow inside \multicolumn when you need both at once.
Merging columns with multicolumn
| Parameter | What it does | Example |
|---|---|---|
| Number of columns | How many adjacent cells to join | 4 |
| Alignment | Column specifier like l, c, r with optional bars | |c| |
| Content | The text or formatting inside the merged cell | Country List |
The \multicolumn command merges adjacent cells in a single row. It takes three parameters: the number of columns to combine, the alignment and borders for the resulting cell, and the text itself.
When you use \multicolumn to span two columns, remember that you drop one column separator in that row because the merged cell takes up the space of two.
Code example for multicolumn
Here is a complete, minimal example showing a header spanning four columns across the top of a table.
Merging rows with multirow
To span cells vertically, add \usepackage{multirow} to your document preamble. The \multirow command takes three parameters: the number of rows to combine, the width of the cell, and the text.
Using an asterisk (*) as the width parameter tells LaTeX to use the natural width of the text. In the rows below the merged cell, you must leave that column blank and omit its text, though you still need to type the cell separator ampersand.
Combining multirow and multicolumn
When a table cell needs to span multiple rows and multiple columns at the same time, you wrap the \multirow command inside a \multicolumn command.
If you write \multirow first with \multicolumn inside it, LaTeX throws a syntax error because the row-merging command expects to control the column structure directly. Always put \multicolumn on the outside, then place \multirow as its content argument.
Common errors and how to fix them
Garbled vertical lines
When a multirow cell sits next to a vertical border, extra lines often poke through. Fix this by matching the vertical line specifier inside the enclosing \multicolumn argument.
Missing text in subsequent rows
If your table text shifts out of place, check that you left the correct number of empty cells with ampersand separators in the rows covered by your \multirow block.
Paragraph mode and line breaks
If you need a paragraph of text inside a merged cell, use a fixed width like \linewidth instead of an asterisk, which allows line wrapping inside the cell.
Questions
Why do I get an error when using multirow in Overleaf?
You likely forgot to add \usepackage{multirow} to your preamble before using the \multirow command in the body of your document.
How do I combine both multirow and multicolumn in the same cell?
Nest the \multirow command inside the content argument of the \multicolumn command. Never put \multicolumn inside \multirow.
What does the asterisk mean in \multirow{3}{*}{text}?
The asterisk tells LaTeX to calculate the column width automatically based on the natural width of the text inside the cell.
Why is text overflowing my merged cell?
If you used an asterisk for the width, the cell will not wrap long sentences. Replace the asterisk with a specific dimension or \linewidth to enable wrapping.
Do I still need to type ampersands for hidden cells under a multirow?
Yes. Even though the text is omitted in rows below the first one, you must keep the column separator ampersands so the rest of the row aligns properly.
How do I draw a horizontal line under only some columns?
Use \cline{2-4} instead of \hline to draw a partial horizontal line that covers only specific columns rather than the entire table width.
Does Texeno support multirow and multicolumn tables?
Yes. Texeno compiles standard LaTeX table packages including multirow, tabularx, and booktabs natively on TeX Live 2026.
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing