All guides

Table in LaTeX

Updated:

A table is built with the tabular environment: the column alignment goes in braces (l, c, r), cells are separated by & and rows end with \\. The table environment adds a caption and a number. The booktabs package gives rules that look like those in published papers.

Measurement table with a caption

\begin{table}[h]
  \centering
  \caption{Measured pendulum periods}
  \label{tab:pendulum}
  \begin{tabular}{ccc}
    \toprule
    $L$ [m] & $t$ [s] & $T$ [s] \\
    \midrule
    0.50 & 14.2 & 1.42 \\
    0.75 & 17.4 & 1.74 \\
    \bottomrule
  \end{tabular}
\end{table}

The ccc columns are centred, and \toprule, \midrule and \bottomrule come from the booktabs package (\usepackage{booktabs}). The caption sits above the table, with \label right after it.

Putting a lab report together? In CamteX you draw formulas and tables, then send the finished document to Overleaf or download it as a PDF. Try it free

Numbers aligned on the decimal point

\usepackage{siunitx}
% ...
\begin{tabular}{S[table-format=1.2] S[table-format=2.1]}
  \toprule
  {$L$ [m]} & {$t$ [s]} \\
  \midrule
  0.50 & 14.2 \\
  0.75 & 17.4 \\
  \bottomrule
\end{tabular}

The S column from siunitx lines numbers up on the decimal marker and prints it according to your settings. Wrap headers in an S column in braces, or siunitx tries to read them as numbers.

A column with wrapping text

\begin{tabular}{l p{8cm}}
  \toprule
  Instrument & Notes \\
  \midrule
  Vernier caliper & Resolution 0.02 mm, ball diameter measured in three places \\
  Stopwatch & Time taken over 10 periods to reduce reaction error \\
  \bottomrule
\end{tabular}

The p{8cm} type makes a fixed-width column in which text wraps like a paragraph. It is useful for tables that describe instruments or add notes to measurements.

Merged header cells

\begin{tabular}{cccc}
  \toprule
  \multicolumn{2}{c}{Series 1} & \multicolumn{2}{c}{Series 2} \\
  \cmidrule(lr){1-2} \cmidrule(lr){3-4}
  $L$ [m] & $T$ [s] & $L$ [m] & $T$ [s] \\
  \midrule
  0.50 & 1.42 & 0.50 & 1.43 \\
  \bottomrule
\end{tabular}

\multicolumn{2}{c}{...} merges two cells into one centred cell. \cmidrule from booktabs draws a short rule under the chosen columns only, and (lr) trims it at both ends.

A wide table

\begin{table}[h]
  \centering
  \small
  \begin{tabular}{lcccccc}
    % ...
  \end{tabular}
\end{table}

When a table does not fit the text width, reduce the font with \small or \footnotesize before tabular. \resizebox works too, but then every table ends up with a different letter size.

Don't want to type it by hand? CSV and Excel to LaTeX table

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free