Free tool

LaTeX table generator. Paste a spreadsheet, get clean code.

Type into the grid or paste from Excel, Google Sheets, CSV or a Markdown table, and get the LaTeX for a finished table: booktabs or grid lines, a caption, a label and every special character escaped. A live preview shows roughly how it will look once typeset.

Free, no sign-up. It runs in your browser.

Your table

Tab moves right, Enter moves down. Paste from a spreadsheet into any cell.

Selected: row 1, column 1.

Replaces the grid. Columns of numbers are right-aligned for you.

Options

Lines

Three horizontal rules, no vertical lines.

Heading rows

Refer to it in your text with Table~\ref{…}.

Font size

Off: characters like % & _ $ are escaped for you.

Preview

Table 1: Pendulum period by length
TrialLength (m)Period (s)
10.251.00
20.501.42
31.002.01

An approximation: LaTeX's fonts and spacing differ slightly.

LaTeX code

4 rows by 3 columns · booktabs · needs \usepackage{booktabs}

% In your preamble:
% \usepackage{booktabs}
\begin{table}[htbp]
  \centering
  \caption{Pendulum period by length}
  \label{tab:pendulum}
  \begin{tabular}{lrr}
    \toprule
    \textbf{Trial} & \textbf{Length (m)} & \textbf{Period (s)} \\
    \midrule
    1 & 0.25 & 1.00 \\
    2 & 0.50 & 1.42 \\
    3 & 1.00 & 2.01 \\
    \bottomrule
  \end{tabular}
\end{table}

How to use it

  1. Step 1: Fill the grid

    Type into the cells, or paste from Excel, Google Sheets, CSV or Markdown. Tab moves right, Enter moves down.

  2. Step 2: Set columns and options

    Pick each column's alignment above the grid, then choose booktabs or grid lines, a caption, a label and the font size.

  3. Step 3: Copy the code

    Copy it or download a .tex file. Add the package line from the top comment to your preamble, once per document.

The anatomy of a LaTeX table

A LaTeX table is two environments, one inside the other. The outer table is a float: it holds the caption and label, and LaTeX moves it to wherever it fits best on the page. The inner tabular is the grid itself. You can use a tabular on its own, but then it can't take a caption and stays exactly where you typed it, even if that leaves a half-empty page.

The tabular's argument lists one letter per column: l, c or r for left, centered or right, and p{3cm} for a column of fixed width whose text wraps onto several lines. Inside, & separates cells and \\ ends a row. A row must never have more cells than the letters allow, which is the cause of most table errors. The float's placement letters, like [htbp], say where LaTeX may put it: here, top of a page, bottom of a page, or a page of floats. Giving all four lets LaTeX choose.

Here is the code the tool writes for the table it opens with, a pendulum's period at three lengths. It starts with a comment, % \usepackage{booktabs}, to remind you which package the preamble needs. Then \begin{table}[htbp] opens the float, \centering centers it, and \caption{Pendulum period by length} and \label{tab:pendulum} follow, in that order. \begin{tabular}{lrr} sets up three columns: the trial number on the left and the two measurements on the right, so their decimal points line up.

Inside, \toprule draws the heavy top line, the heading row reads \textbf{Trial} & \textbf{Length (m)} & \textbf{Period (s)} \\, and \midrule separates it from the data. The data rows are 1 & 0.25 & 1.00 \\ then 2 & 0.50 & 1.42 \\ then 3 & 1.00 & 2.01 \\. Finally \bottomrule closes the grid, and \end{tabular} and \end{table} close the environments. The periods come from T = 2π√(L/g) with g = 9.81 m/s², rounded to two decimal places.

The label is what lets you write Table~\ref{tab:pendulum} in your text and get the right number, even after tables are added or moved. It has to come after the caption, because \label picks up the most recent number LaTeX has assigned: put it first and \ref prints the section number instead. References also need two runs of LaTeX to settle, which is why a fresh one shows ?? until you compile again.

Why booktabs tables look more professional

LaTeX's own \hline draws every line the same weight with almost no space around it, so the text sits cramped against the rules. The booktabs package replaces it with three rules: \toprule and \bottomrule, which are heavier, and a lighter \midrule under the headings. They also leave a little vertical space between each rule and the text, which is most of why a booktabs table looks like it came out of a journal.

The package's documentation by Simon Fear is blunt about the rest. Its first two guidelines for a formal table are to never, ever use vertical rules, and never use double rules. It also advises putting units in the column heading rather than repeating them in every cell, always writing a digit before a decimal point (0.1, not .1), and never using ditto marks. If the two halves of a table seem to need a vertical line between them, Fear suggests they should be two tables.

For grouped headings, booktabs adds \cmidrule, a thin rule under part of a row. When you merge heading cells with this tool and use two heading rows, it writes \multicolumn{2}{c}{...} over the group and \cmidrule(lr){2-3} beneath it. The (lr) trims both ends slightly, so two group rules side by side don't run into each other.

One spacing detail: booktabs puts no space above \toprule by default, so a caption placed above the table can sit tight against the top rule. The documentation suggests setting \abovetopsep in your preamble, for example \setlength{\abovetopsep}{4pt}, rather than adding \vspace to every table. The caption package can fix it too, with its tableposition=top option. The grid style is still here for the times a teacher or template asks for every line, but if the choice is yours, booktabs is the better default.

Common errors and how to fix them

Misplaced alignment tab character &. LaTeX reads & as a cell separator, so a bare & anywhere outside a tabular, such as a caption reading R&D, stops the compile with this message. Inside a tabular a stray & quietly pushes the rest of the row one column to the right, or, if the row is already full, causes the Extra alignment tab error described below. Write \& when you mean the symbol. The tool does this for you in cells and captions.

Unescaped % and _. A % starts a comment, so LaTeX ignores the rest of that line, including the \\ that ends the row, and the next row runs into it. An underscore only means something in math mode, so a cell like x_1 stops the compile with Missing $ inserted. With escaping on, Growth (%) becomes Growth (\%) and x_1 becomes x\_1. The same goes for $, #, {, }, ~, ^ and the backslash. If your cells are meant to contain math, turn escaping off and write it as $x_1$ yourself; the tool then flags an unescaped & or %, an unclosed $ or unbalanced braces before you hit compile.

Extra alignment tab has been changed to \cr. A row has more cells than the column specification allows: {lrr} takes three cells, so two & per row. Count the letters and the &s, or let the tool write both from the same grid so they can't disagree. A missing \\ at the end of a row causes the same error, because the next row's cells are added onto it.

LaTeX doesn't recognize \toprule. If the compile stops at \toprule, \midrule or \bottomrule and says the control sequence isn't defined, the booktabs package isn't loaded. Add \usepackage{booktabs} to the preamble, between \documentclass and \begin{document}. The top comment in the generated code lists every package the table needs; the float package appears only when you choose [H] placement, which pins the table exactly where it is in the text.

Wide tables, and pasting from spreadsheets

When a table is wider than the text block, start by making it smaller honestly: shorter headings with the units in them, fewer columns, or the \small or \footnotesize option. For columns of prose, switch them to wrapped p columns with a fixed width. For a table that should fill the line exactly, the tabularx package's X columns share out whatever width you give, as in \begin{tabularx}{\textwidth}{lXX}.

It is tempting to wrap the tabular in \resizebox{\textwidth}{!}{...} from the graphicx package. It works, but it scales the text along with the lines, so the table ends up in a font size that matches nothing else in the document, and a wide table can shrink to unreadable. Use it as a last resort. For a genuinely wide table, turn it sideways instead: the rotating package's sidewaystable environment puts it on a page of its own in landscape, and the landscape environment from pdflscape also rotates the page in PDF viewers. A table that runs over several pages needs the longtable package.

To bring data in from Excel or Google Sheets, select the cells and copy. The clipboard holds them as tab-separated text, with any cell that contains a line break wrapped in quotes, and that's what the paste box reads; it also takes CSV with commas or semicolons and Markdown tables. You can paste straight into any cell of the grid too, and it fills from there like a spreadsheet. Columns that hold only numbers are right-aligned for you. Round the numbers in the spreadsheet first, since a copy carries what the cell displays, not the full value behind it. If you need numbers aligned on the decimal point, the siunitx package's S column does that.

Tables of results often sit next to equations. For those, the LaTeX equation editor previews an expression as you type, so you can paste it into a cell with escaping turned off.

Sources

  1. Fear, S. (2020). Publication quality tables in LaTeX (booktabs package documentation, v1.61803398). CTAN, the Comprehensive TeX Archive Network.

Study from the LaTeX you write

If your notes or problem sets are written in LaTeX, you can upload the .tex files to Skolight as study material, alongside PDFs and slides. It works from the written text in the source rather than the equations, and turns it into structured notes, a quiz or a set of flashcards to revise from.

See the AI Note Taker

Questions.

More free tools. No sign-up either.

  • Free tool

    LaTeX Equation Editor

    A live LaTeX preview with a symbol palette, plain-English errors, and MathML, PNG and SVG export.

  • Free tool

    Truth Table Generator

    The full truth table for any logic formula, with steps, a tautology check and an equivalence test.

  • Free tool

    Citation Generator

    Citations in APA, MLA, Chicago and Harvard, with DOI and ISBN lookup and a sorted bibliography.

Want this done for you? Start from your own notes.

Skolight turns your lectures and readings into flashcards, quizzes, mock exams and a study plan. The Free plan needs no card.

  • No card requiredGet started in seconds
  • Trusted by 100k+ studentsJoin a growing community
  • Works with any documentPDFs, notes, slides and more