LaTeX Basics

5. Tables and Matrices

Organizing data into rows and columns.

7 min read Share

Tables organize data into rows and columns using the tabular environment.

Level 1: Basic Grid

Use & to separate columns and \\ to end rows. The {| l | c | r |} defines alignment (Left, Center, Right) and vertical lines.

Source Code
Example OutputStatic
\begin{tabular}{ | l | c | r | } \hline Item & Qty & Price \\ \hline Widget & 42 & $10.00 \\ Gadget & 13 & $19.99 \\ \hline \end{tabular}
ItemQtyPrice
Widget42$10.00
Gadget13$19.99

Level 2: Merging Cells

Use \multicolumn to span multiple columns.

LaTeX
\begin{tabular}{|c|c|}
  \hline
  \multicolumn{2}{|c|}{Team Stats} \\
  \hline
  Wins & Losses \\
  \hline
\end{tabular}

Level 3: Professional Tables

Publication-quality tables eschew vertical lines. Use the booktabs package.

LaTeX
\usepackage{booktabs}

\begin{tabular}{llr}
  \toprule
  Item & Qty & Price \\
  \midrule
  Apple & 5 & $1.00 \\
  Pear & 10 & $2.00 \\
  \bottomrule
\end{tabular}