Basic Tables, Multicolumn Cells, and Long Tables
Use tabular for a single-page table, booktabs for clear horizontal rules, and longtable when a table must span pages. Design tables for comparison and lookup, not as a grid for long prose.
EasyLaTeX compiler setting: pdfLaTeX with article. Load booktabs; multipage tables also need longtable.
A Minimal Table
Column letters specify left, centered, and right alignment: l, c, and r. Separate cells with & and end a row with \\:
\begin{tabular}{lcr}
Name & Group & Value \\
Sample A & Control & 12.3 \\
Sample B & Treatment & 15.8 \\
\end{tabular}
Right alignment helps compare numbers; it does not itself align decimal points exactly. Specialized numeric columns can provide that when needed.
Clear Horizontal Rules
After loading booktabs, use \toprule, \midrule, and \bottomrule:
\usepackage{booktabs}
\begin{tabular}{lcr}
\toprule
Name & Group & Value \\
\midrule
Sample A & Control & 12.3 \\
Sample B & Treatment & 15.8 \\
\bottomrule
\end{tabular}
Their spacing and weight are designed for readable tables. Vertical lines and a rule after every row are usually unnecessary.
Fixed-Width Text Columns
p{width} creates a paragraph column with automatic wrapping:
\begin{tabular}{lp{7cm}r}
\toprule
ID & Description & Score \\
\midrule
A1 & This longer description wraps within the specified width. & 95 \\
\bottomrule
\end{tabular}
If the table is too wide, shorten headings, wrap text, or split it. Do not automatically shrink all text with \resizebox.
Spanning Columns
\multicolumn{count}{alignment}{content} spans columns:
\begin{tabular}{lcc}
\toprule
\multicolumn{1}{c}{Sample} & \multicolumn{2}{c}{Measurements} \\
\cmidrule(lr){2-3}
Name & First & Second \\
\midrule
A & 12.3 & 12.6 \\
B & 15.8 & 16.1 \\
\bottomrule
\end{tabular}
\cmidrule(lr){2-3} draws a partial rule across columns 2–3, useful for grouped headings.
Tables Across Pages
tabular does not break automatically across pages. Use longtable without enclosing it in a table float:
\usepackage{longtable}
\usepackage{booktabs}
\begin{longtable}{llr}
\caption{Sample measurement log}\label{tab:measurements} \\
\toprule
ID & Date & Value \\
\midrule
\endfirsthead
\toprule
ID & Date & Value \\
\midrule
\endhead
A1 & 2026-07-01 & 12.3 \\
A2 & 2026-07-02 & 12.6 \\
% Add more rows; the table breaks across pages automatically.
\bottomrule
\end{longtable}
The material before \endfirsthead is the first-page heading; the next heading ends at \endhead and is used on later pages. Page-breaking tables do not follow ordinary float placement.
Common Problems
Extra alignment tab has been changed to \cr
Compare separators with the column count. An ordinary three-column row has two separating & characters. Escape an ampersand that is part of the cell text as \&; account for merged cells separately.
The Table Exceeds the Margins
Use paragraph columns for long text, simplify headings, or split the table. Consider landscape or scaling only after those options.
A Long Table Has Unexpected Placement
Do not nest longtable inside table; they have different page-placement mechanisms.
Complete Example
\documentclass[a4paper,12pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[tbp]
\centering
\caption{Sample measurements}
\label{tab:results}
\begin{tabular}{lcr}
\toprule
Name & Group & Value \\
\midrule
Sample A & Control & 12.3 \\
Sample B & Treatment & 15.8 \\
\bottomrule
\end{tabular}
\end{table}
Table \ref{tab:results} summarizes the measurements for two samples.
\end{document}