LaTeX Guide

LaTeX Tables

tabular for the grid, table for the float wrapper, booktabs for professional rules. The combo every published paper uses.

The professional pattern (booktabs)

\usepackage{booktabs}

\begin{table}[t]
  \centering
  \caption{Performance comparison.}
  \label{tab:results}
  \begin{tabular}{l r r}
    \toprule
    Method  & Accuracy & Latency \\
    \midrule
    Baseline & 75.2     & 12.3 ms \\
    Ours     & 91.4     &  8.7 ms \\
    \bottomrule
  \end{tabular}
\end{table}

Column alignments

SpecEffect
lLeft-aligned
cCenter-aligned
rRight-aligned (good for numbers)
p{3cm}Fixed-width paragraph cell (wraps)
XAuto-stretch (tabularx only)
|Vertical line (avoid in published tables)

Multi-column header

\begin{tabular}{l c c c c}
  \toprule
       & \multicolumn{2}{c}{Group A} & \multicolumn{2}{c}{Group B} \\
  \cmidrule(lr){2-3} \cmidrule(lr){4-5}
  Item & X & Y & X & Y \\
  \midrule
  Foo  & 1 & 2 & 3 & 4 \\
  Bar  & 5 & 6 & 7 & 8 \\
  \bottomrule
\end{tabular}

Multi-row cell

\usepackage{multirow}

\begin{tabular}{l l c}
  \toprule
  Group & Item & Value \\
  \midrule
  \multirow{2}{*}{A} & X & 1 \\
                     & Y & 2 \\
  \midrule
  \multirow{2}{*}{B} & X & 3 \\
                     & Y & 4 \\
  \bottomrule
\end{tabular}

Auto-fit to page width

\usepackage{tabularx}

\begin{table}[t]
  \caption{Stretchable table.}
  \begin{tabularx}{\textwidth}{l X X}
    \toprule
    Method & Description (stretches) & Result (stretches) \\
    \midrule
    A & Short & 1.2 \\
    B & A longer description that wraps & 3.4 \\
    \bottomrule
  \end{tabularx}
\end{table}

Common mistakes

  • Using \hline instead of booktabs. Looks amateur. Use \toprule, \midrule, \bottomrule.
  • Adding vertical lines. Tufte/booktabs convention says no vertical rules in scientific tables.
  • Caption below the table. Tables get captions ABOVE; figures get them below.
  • Using tabular for very long tables. Use longtable for tables that span pages.
  • Not loading booktabs. Most professional templates require it.
Typst tables: just call table()
#table(
  columns: (auto, auto, auto),
  align: (left, right, right),
  [Method], [Accuracy], [Latency],
  [Baseline], [75.2], [12.3 ms],
  [Ours], [91.4], [8.7 ms],
)

No environment, no booktabs to install. Try TypeTeX free.

Try TypeTeX free

Frequently Asked Questions

How do I create a table in LaTeX?

Use the tabular environment: \begin{tabular}{l c r} A & B & C \\ 1 & 2 & 3 \end{tabular}. The {l c r} specifies column alignments (left, center, right). Columns are separated by &, rows by \\. Wrap in a table environment for captioning and float positioning.

What's the difference between table and tabular?

tabular is the actual grid of cells. table is a 'float' wrapper that adds caption, label, and lets LaTeX move the table to a good position on the page. Almost always you want both: \begin{table} ... \caption{...} \begin{tabular}{...} ... \end{tabular} \end{table}.

Why do my LaTeX tables look bad with default rules?

Default \hline rules look amateurish. Use the booktabs package: \usepackage{booktabs}, then \toprule, \midrule, \bottomrule for the three professional horizontal rules. No vertical lines. This is the standard for journal/conference papers.

How do I merge cells across columns (multicolumn)?

\multicolumn{2}{c}{Merged Header} merges 2 columns and centers the content. The first arg is the number of columns, the second is the column spec (l, c, r), the third is the content. Replaces 2 of the column-separator & for that row.

How do I merge cells across rows (multirow)?

Load \usepackage{multirow}, then \multirow{3}{*}{Content} merges 3 rows. The * means 'natural width'. Place it in the first row of the merge; subsequent merged rows leave that column empty.

How do I auto-fit a table to page width?

Use the tabularx package: \usepackage{tabularx}, then \begin{tabularx}{\textwidth}{lXX} where X columns flexibly stretch to fit. Or use \begin{tabular*}{\textwidth}{...} with @{\extracolsep{\fill}} for fixed columns + variable space.

How do I add a caption to my table?

Inside the table environment: \caption{Your caption text}. Place it ABOVE the tabular for tables (convention is caption above tables, below figures). Add \label{tab:name} after the caption to enable cross-referencing with \ref or \autoref.

How do I number cells with decimals aligned?

Use the siunitx package: \usepackage{siunitx}, then column type S aligns on decimal points. \begin{tabular}{l S[table-format=2.3]} Item & 1.234 \\ Other & 12.345 \end{tabular}. The numbers align by their decimal points regardless of integer length.

Why does my long table break across pages?

tabular doesn't break across pages — it'll overflow. Use the longtable package: \usepackage{longtable}, then \begin{longtable}{l c r} ... \end{longtable}. Captions and headers can repeat on each page. Don't put longtable inside a table environment — it manages its own floats.

More LaTeX guides