The multirow package

Provides \multirow, a table cell that spans several rows, with its text centred vertically across them.

Loading the package

\usepackage{multirow}

LaTeX itself has \multicolumn for a cell across columns and nothing for rows. \multirow{3}{*}{Text} goes into the first of the three rows. In the rows below, the cell stays empty, but its & is still written.

The second argument is the width of the cell. * means the natural width of the text, a length such as 2cm wraps the text, and = takes the width of the column when that width is fixed, as in a p{3cm} column.

Main commands

\multirow{3}{*}{Fruit}Cell across 3 rows in the natural width of the text.
\multirow{2}{2cm}{Root vegetables}Cell across 2 rows, 2 cm wide, with wrapped text.
\multirow[t]{2}{*}{Text}Aligns the text with the top row instead of centring it; [b] aligns with the bottom row.
\multirow{2}{*}[-2pt]{Text}Moves the text down by 2 pt, to correct the position by hand.
\multirow{-2}{*}{Text}Negative number: the cell extends upwards from the last of its rows.
\cline{2-3}Horizontal line under columns 2 to 3 only, so it does not cut through the cell.
\multicolumn{2}{c}{\multirow{2}{*}{Text}}Cell across two columns and two rows; \multirow goes inside \multicolumn.

Complete example

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|l|l|r|}
\hline
Group & Item & Price \\ \hline
\multirow{3}{*}{Fruit} & Apple  & 0.50 \\ \cline{2-3}
                       & Banana & 0.25 \\ \cline{2-3}
                       & Cherry & 3.00 \\ \hline
\multirow{2}{2cm}{Root vegetables}
                       & Carrot & 0.30 \\ \cline{2-3}
                       & Beet   & 0.60 \\ \hline
\end{tabular}
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages