How to make a table in LaTeX
Published by InstantToolDeck · Updated November 2026
Tables are one of the first things that trip up new LaTeX users. The syntax is compact but unforgiving, and a missing ampersand can produce pages of errors. This guide explains how tables work, from the first example to merged cells, and shows how to avoid the usual mistakes. To skip the typing, build the table visually with the LaTeX table generator and copy the code.
The basic table
\begin{tabular}{lcr}
Name & Score & Time \\
Ann & 9.5 & 1.2 \\
Bob & 7.0 & 0.8 \\
\end{tabular}
The argument {lcr} says the table has three columns: left-aligned, centered and right-aligned. Cells in a row are separated by &, and each row ends with \\. Everything between \begin{tabular} and \end{tabular} is the table body.
Column types
l,c,r: left, centered, right.p{3cm}: a paragraph column of fixed width, with text that wraps.|: a vertical line between columns, for example{|l|c|r|}.
Numbers read best right-aligned, and text left-aligned. For aligning decimal points, look at the siunitx package and its S column type.
Adding lines
Plain LaTeX draws a horizontal line with \hline before or after a row. Vertical lines come from the column specification. A full grid looks busy, though, and professional typesetting usually avoids it. The booktabs package provides \toprule, \midrule and \bottomrule with better spacing:
\usepackage{booktabs} % in the preamble
\begin{tabular}{lcr}
\toprule
Name & Score & Time \\
\midrule
Ann & 9.5 & 1.2 \\
Bob & 7.0 & 0.8 \\
\bottomrule
\end{tabular}
Captions, labels and floats
To give a table a number, a caption and a label that you can reference, wrap it in a table environment:
\begin{table}[htbp]
\centering
\caption{Results of the experiment.}
\label{tab:results}
\begin{tabular}{lcr} ... \end{tabular}
\end{table}
In the text, write Table~\ref{tab:results}. The placement letters htbp allow LaTeX to put the table here, at the top, at the bottom or on a separate page. Put the caption above the table, which is the convention for tables, and below for figures.
Merged cells
To span several columns use \multicolumn{2}{c}{Text}. To span rows, load multirow and use \multirow{2}{*}{Text}. Both can be combined, and partial horizontal lines are drawn with \cline{2-3}. Doing this by hand is error-prone, which is where a visual editor helps.
Special characters in cells
The characters & % $ # _ { } ~ ^ \ need escaping: write 50\%, R\&D and file\_name. An unescaped ampersand adds an extra column and causes the dreaded “Extra alignment tab has been changed to \cr” error.
Tables that are too wide
If a table runs past the margin, try a smaller font with \small, shorter column titles, p{} columns for long text, the tabularx package, or scaling the whole table with \resizebox{\textwidth}{!}{...}. Scaling is easy but changes the font size, so use it sparingly.
Importing data from a spreadsheet
Typing a large table by hand is slow. Copy the cells from Excel or Google Sheets and paste them into the generator, which places them in the grid and writes the code. CSV data can be pasted into the same box, and the CSV and JSON converter helps when your data starts out as JSON.
Common errors
- Misplaced \noalign: a rule such as
\hlineor\midrulein the wrong place, often right after another rule or before the first row. - Extra alignment tab: more
&than columns in a row. - Missing \item or Missing $: an unescaped special character, such as an underscore.
- Undefined control sequence \toprule: booktabs is not loaded.
Frequently asked questions
How do I add a caption to a LaTeX table?
Wrap the tabular in a table environment and add \caption{...} above it. Add \label{...} after the caption to reference it.
How do I make a table fit the page width?
Use p{} or tabularx columns, shorten the content, or wrap the tabular in \resizebox{\textwidth}{!}{...}.
Do I need a package for tables?
Plain tabular needs none. booktabs, multirow and tabularx add useful features.