LaTeX Table Generator
Type into the grid or paste cells straight from Excel, Google Sheets or a CSV file, and the LaTeX code updates as you go. Merge cells, set column alignment, choose booktabs or bordered styles and add a caption and label, then copy the code into Overleaf or your .tex file.
Last updated:
An approximation of the typeset table; spacing in your PDF depends on the document class.
How to use the LaTeX Table Generator
- Fill the grid: type in the cells, paste a range copied from a spreadsheet into the top-left cell, or use Import CSV / Excel.
- Set column alignment with the menu above each column; choose Wrap p{} for long text and set the width.
- Merge cells: drag across cells or Shift+click to select a range and press Merge cells. Select a merged cell and press Split cell to undo.
- Choose a style such as booktabs for papers, then add a caption and a label like tab:results for \ref.
- Copy LaTeX into your document and add the packages listed under the code, or download a complete .tex file to compile.
Anatomy of a LaTeX table
A LaTeX table has two layers. The tabular environment draws the grid itself; the optional table float around it adds the caption, the label and lets LaTeX move the table to a good spot on the page.
| Code | What it does |
|---|---|
\begin{tabular}{lcr} | One letter per column: l left, c center, r right. p{3cm} makes a column of fixed width whose text wraps. A | between letters draws a vertical line. |
& and \\ | & moves to the next cell, \\ ends the row. |
\hline, \cline{2-3} | A line across the full table, or only across columns 2 to 3. |
\toprule \midrule \bottomrule | booktabs rules: thick top and bottom, thin rule under the header, with extra vertical padding. |
\cmidrule(lr){2-3} | A booktabs partial rule, trimmed on the left and right, often placed under a grouped header. |
\multicolumn{2}{c}{Text} | One cell spanning 2 columns with its own alignment. |
\multirow{2}{*}{Text} | One cell spanning 2 rows (multirow package); the row below leaves that cell empty. |
\begin{table}[htbp] | Float placement preferences: here, top, bottom, separate page. [H] (float package) forces the exact spot. |
\caption{...}\label{tab:x} | Numbered caption and a key for \ref{tab:x}. The label must come after the caption. |
Characters that must be escaped
| Character | Meaning in LaTeX | Write instead |
|---|---|---|
& | Column separator | \& |
% | Starts a comment | \% |
$ | Math mode | \$ |
# | Macro parameter | \# |
_ and ^ | Subscript and superscript (math only) | \_ and \textasciicircum{} |
{ } | Grouping | \{ \} |
~ | Non-breaking space | \textasciitilde{} |
\ | Starts a command | \textbackslash{} |
Tips for publication-quality tables
- Skip vertical lines. Most style guides (and the booktabs documentation) recommend horizontal rules only; white space separates columns well enough.
- Put the caption above the table. Readers scan a table from the top, which is why journals usually place table captions above and figure captions below.
- Right-align numbers with the same number of decimals so digits line up. For alignment on the decimal point, the
siunitxpackage offers anScolumn type. - Put units in the header, for example “Time (s)”, instead of repeating them in every cell.
- Group related columns under a merged header and underline it with
\cmidrule; this generator adds the rule automatically when you merge cells in a header row.
Frequently asked questions
How do I convert an Excel table to LaTeX?
Select the cells in Excel or Google Sheets and copy them, click the first cell of the grid here and paste. The rows and columns are filled in (the grid grows if needed) and the LaTeX tabular code appears instantly. You can also save the sheet as CSV and open it with Import CSV / Excel.
What is booktabs and why use it?
booktabs is a LaTeX package that adds \toprule, \midrule and \bottomrule: horizontal rules of different weights with better spacing than \hline. It is the standard look in academic papers and journals, which generally discourage vertical lines. Add \usepackage{booktabs} to your preamble.
How are merged cells written in LaTeX?
Cells merged across columns use \multicolumn{n}{c}{text}. Cells merged across rows use \multirow{n}{*}{text} from the multirow package, and the rows below get an empty cell in that position. With bordered styles the generator uses \cline so lines are not drawn through a multirow cell.
Why does my table break when the text contains & or %?
In LaTeX & separates columns, % starts a comment and $ _ ^ # { } ~ \ have special meanings, so they must be escaped (\& \% \$ and so on). Keep Escape special characters switched on for plain text. Switch it off only when your cells contain LaTeX on purpose, such as $\alpha$ or \textit{...}.
My table is too wide for the page. What can I do?
Set long text columns to Wrap p{} with a width like 4cm so the text wraps, pick a smaller font size such as \small, or shorten headers. For very wide tables you can wrap the tabular in \resizebox{\textwidth}{!}{...} from the graphicx package, although scaling makes text smaller than the body.
How do I reference the table in my text?
Give it a label such as tab:results; the generator places \label after \caption, which is required for correct numbering. Then write Table~\ref{tab:results} in your text. Compile twice so LaTeX resolves the reference.
Does it work with Overleaf?
Yes. The output is standard LaTeX that works with pdfLaTeX, XeLaTeX and LuaLaTeX, including Overleaf. Paste the code into the document body and add the listed \usepackage lines to the preamble.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.