# Multi-column and multi-row cells in LaTeX tables

I always forget how to do this. If you have the same problem, here is a quick post for your bookmarks…

##### Basic commands
%multi-column
\multicolumn{number cols}{align}{text} % align: l,c,r

%multi-row
\usepackage{multirow}

\multirow{number rows}{width}{text}

Using * as width in the multirow command, the text argument’s natural width is used (multirow package documentation).

##### Multiple columns
\documentclass[11pt]{article}
\begin{document}

\begin{table}[ht]
\caption{Multi-column table}
\begin{center}
\begin{tabular}{cc}
\hline
\multicolumn{2}{c}{Multi-column}\\
X&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}

\end{document}

##### Multiple rows
\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}

\begin{table}[ht]
\caption{Multi-row table}
\begin{center}
\begin{tabular}{cc}
\hline
\multirow{2}{*}{Multirow}&X\\
&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}

\end{document}

##### Multiple rows and columns
\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}

\begin{table}[ht]
\caption{Multi-column and multi-row table}
\begin{center}
\begin{tabular}{ccc}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{Multi-col-row}}&X\\
\multicolumn{2}{c}{}&X\\
\hline
X&X&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}

\end{document}

The examples provided are very basic. Drop me a comment below in case you are having problems with a more complex table. Also, the color is just for illustration purposes and for simplicity reasons not part of the minimal working examples above. See here for how to color table columns or rows.

##### Partial horizontal line

Use \cline{columns} for a horizontal line spanning one or several table columns.

\documentclass[11pt]{article}
\begin{document}

\begin{table}[ht]
\caption{Partial horizontal line}
\begin{tabular}{ccc}
\hline
\multicolumn{2}{c}{Multi-column}&\\
\cline{1-2}
X&X&X\\
X&X&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}

\end{document}

#### 4 Responses to “Multi-column and multi-row cells in LaTeX tables”

• AlBundy

Hi,

in the multiple columns and multiple rows examples, are you sure pictures match with code?. I think alignment of “X” is not “c”.

• tom

Right, I used a more complex column definition and changed the code to keep it as simple as possible. Also, the color is not reproduced by the example.

• Rachael

Hi. Thanks for the help. I am having trouble with multiple multirows in a table. It doesn’t seem to recognise that the second multirow exists. Any ideas?

• tom

Hi Rachael,
Here is an example with multiple multirows in a table. If this doesn’t help solving your issue, please provide a minimal example.

Thanks, Tom

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\caption{Multi-row table}
\centering
\begin{tabular}{ccc}
\hline
\multirow{2}{*}{Multirow}&X&\multirow{2}{*}{Multirow}\\
&X&\\
X&\multirow{2}{*}{Multirow}&\multirow{2}{*}{Multirow}\\
X&&\\
\hline
\end{tabular}
\label{tab:multirow}
\end{table}
\end{document}