Skip to content

LaTeX table generator

Fill in the grid or paste cells from Excel, and get a tabular that compiles on the first try, with booktabs rules, a caption and a label for \ref.

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.

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.

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.