Tables

Merging rows and columns

  • To merge columns: \multicolumn{cell count}{layout}{content}

  • To merge rows: \multirow{cell count}{layout}{content}

Example:

\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|c|}{Table cheat sheet} \\
\hline
Horizontal line & \hline  & underlines current table row \\ \hline
\multirow{4}{*}{Column types} & l  & left \\
 & \verb|c|  & center\\
 & \verb|r|  & right\\
 & \verb|p{'width'}|  & custom width, aligned top \\
 & \verb|m{'width'}|  & custom width, aligned middle \\
 & \verb|b{'width'}|  & custom width, aligned bottom \\ \hline
\multirow{3}{*}{Borders} & none & default \\
 & \verb,|,  & single, as in \verb,l|,  \\
 & \verb,||,  & double, as in \verb,l||c,  \\ \hline
Alignment & \& & separates columns \\ \hline
\multirow{2}{*}{End of line} & \verb|\\|  & new table row \\
 & \verb|newline|  & new line within cell \\
\hline
\end{tabular}
Table cheat sheet
Horizontal line \hline underlines current table row
Column types l left
c center
r right
p{'width'} custom width, aligned top
m{'width'} custom width, aligned middle11requires array.sty
b{'width'} custom width, aligned bottom22requires array.sty
Borders none default
| single, as in l|
|| double, as in l||c
Alignment & separates columns
End of line \\ new table row
newline new line within cell