How to Create Tables in LaTeX
From basic grids to publication-quality tables with booktabs.
Basic Tables
Tables in LaTeX are created with the tabular environment. You define columns in the argument, separate cells with &, end rows with \\, and add horizontal lines with \hline:
\begin{tabular}{l c r}
\hline
Name & Age & Score \\
\hline
Alice & 23 & 95 \\
Bob & 27 & 88 \\
Claire & 21 & 92 \\
\hline
\end{tabular}
This produces a three-column table with the first column left-aligned, the second centered, and the third right-aligned.
Build and compile this table instantly in our online editor.
Try it in our editorColumn Alignment
The column specification string accepts these alignment options:
l-- left-alignedc-- centeredr-- right-alignedp{width}-- paragraph column with fixed width (text wraps)|-- vertical line between columns
% Table with vertical lines and a paragraph column:
\begin{tabular}{|l|c|p{6cm}|}
\hline
Feature & Status & Description \\
\hline
Speed & Fast & Compiles documents in under a second
on modern hardware. \\
\hline
Quality & High & Produces publication-ready output with
professional typography. \\
\hline
\end{tabular}
Professional Tables with Booktabs
The booktabs package replaces \hline with three commands that produce cleaner, more professional horizontal rules. Most journals and publishers prefer this style:
\usepackage{booktabs}
% In the document body:
\begin{tabular}{lcc}
\toprule
Method & Precision & Recall \\
\midrule
Baseline & 0.72 & 0.68 \\
Ours & 0.89 & 0.85 \\
Ours+ & 0.93 & 0.91 \\
\bottomrule
\end{tabular}
Use \toprule at the top, \midrule after the header row, and \bottomrule at the bottom. Avoid vertical lines when using booktabs -- the clean horizontal rules are sufficient.
Multicolumn and Multirow
To span a cell across multiple columns, use \multicolumn. For spanning rows, use the multirow package:
\usepackage{multirow}
\usepackage{booktabs}
\begin{tabular}{lccc}
\toprule
\multirow{2}{*}{Model} & \multicolumn{3}{c}{Metrics} \\
\cmidrule(lr){2-4}
& Accuracy & F1 & AUC \\
\midrule
Linear & 0.78 & 0.75 & 0.82 \\
Neural Net & 0.91 & 0.89 & 0.94 \\
\bottomrule
\end{tabular}
The \multicolumn{3}{c}{Metrics} command merges three cells and centers the label. The \cmidrule(lr){2-4} adds a partial rule under columns 2 through 4 with trimmed ends.
Experiment with multicolumn and multirow tables in our live editor.
Try it in our editorTable Positioning
Wrap your tabular in a table environment to make it a floating element with a caption and label for cross-referencing:
\begin{table}[h]
\centering
\caption{Experimental results on the test set.}
\label{tab:results}
\begin{tabular}{lcc}
\toprule
Method & Accuracy & Speed (ms) \\
\midrule
A & 92.3 & 12 \\
B & 94.1 & 18 \\
\bottomrule
\end{tabular}
\end{table}
The placement specifier [h] suggests placing the table "here." Other options are [t] (top), [b] (bottom), and [p] (dedicated float page). You can reference the table with \ref{tab:results} elsewhere in your document.
Common Mistakes
- Missing
\\at end of rows -- every row except the last before\end{tabular}needs a row terminator, though adding one on the last row is harmless. - Wrong number of
&separators -- each row must have exactly one fewer&than the number of columns. - Using
\hlinewith booktabs -- do not mix\hlinewith\toprule/\midrule/\bottomrule. Choose one style. - Forgetting
\centering-- without it, tables left-align within the float, which usually looks odd.