Skip to content

LaTeX table generator

Fill in the grid or paste cells from Excel (or an existing LaTeX table) and get code that compiles first time: booktabs, tabularx or longtable, with a caption, a label, landscape and scaling options.

Anatomy of a LaTeX table

  • \begin{table}[htbp]: the float, which lets LaTeX place the table here, top, bottom or on its own page, and carries the caption and label.
  • \begin{tabular}{l c r}: the grid itself. Each letter is a column: l left, c center, r right, p{3cm} wrapped text.
  • & separates cells and \\ ends a row.
  • \toprule, \midrule and \bottomrule (booktabs) or \hline draw the horizontal rules.

The booktabs documentation (Simon Fear, CTAN) sets out two rules worth following: never use vertical rules, and never use double rules. The default output here follows both.

Start from a spreadsheet

Have the numbers in a file already? Excel to LaTeX and CSV to LaTeX convert a whole sheet in one go.

Aligning numbers on the decimal point

For columns of figures, right alignment is usually enough. For true decimal alignment, load the siunitx package and change that column's letter to S.

Which environment should I use?

You needUsePackage
A normal table that fits on the pagetabular inside table(none; booktabs for nicer rules)
Columns with long text that should wrap to the text widthtabularx with X columnstabularx
A table longer than one pagelongtablelongtable
A wide table rotated 90°sidewaystablerotating
A table that is just slightly too wide\resizebox{\linewidth}{!}{…}graphicx
Numbers aligned on the decimal pointS columnssiunitx

Writing for Typst instead? Use the Typst table generator. Need to get a table out of a .tex file? Use LaTeX to CSV.

Questions people ask

What is booktabs and should I use it?

booktabs is a LaTeX package that adds \toprule, \midrule and \bottomrule: rules with proper weight and spacing. Most journals and style guides recommend it over \hline and vertical lines. Add \usepackage{booktabs} to your preamble.

Which characters need escaping in a LaTeX table?

The ten special characters & % $ # _ { } ~ ^ \ must be escaped, and & is especially important because it separates columns. The generator converts them to \&, \%, \$, \#, \_, \{, \}, \textasciitilde{}, \textasciicircum{} and \textbackslash{}.

How do I reference the table in my text?

Keep “Wrap in table float” on and set a label such as tab:results. Then write Table~\ref{tab:results} in your text, and LaTeX fills in the number.

Why is my table too wide for the page?

tabular never wraps text. Shorten the headers, use p{3cm} columns for long text, reduce the font with \small before the tabular, or wrap it in \resizebox{\linewidth}{!}{…} from the graphicx package as a last resort.

How do I generate a table in LaTeX?

Put a tabular environment inside a table float: \begin{table}[htbp] \centering \begin{tabular}{l c r} … \end{tabular} \caption{…} \end{table}. Separate cells with & and end each row with \\. Or fill in the grid above (or paste from Excel) and copy the generated code.

Can I create LaTeX tables online?

Yes. This page builds the LaTeX in your browser as you type, with a live preview, and you can paste cells from Excel, Google Sheets, CSV, Markdown or an existing LaTeX table. Tick “Full document” to get a file that compiles on its own in Overleaf or any TeX distribution.

How do I make a table span multiple pages?

Choose the longtable environment. It replaces table + tabular, repeats the header on each new page (\endhead) and needs \usepackage{longtable}. A table float can never break across pages.

How do I make the table fit the page width?

Use tabularx with X columns, which share the remaining width and wrap their text. Alternatively, keep tabular and tick “Scale to \linewidth”, which wraps it in \resizebox from graphicx. That shrinks the font too, so use it for slightly-too-wide tables only.

How do I merge cells in LaTeX?

Horizontally with \multicolumn{3}{c}{Text}, which spans three columns; vertically with \multirow{2}{*}{Text} from the multirow package. Write them in the generated code where you need them; the importer understands \multicolumn when you paste a table back in.

Does it work in Overleaf?

Yes. The output is standard LaTeX. Paste it into your .tex file in Overleaf and add \usepackage{booktabs} if you left booktabs on.