LaTeX Tables Generator
How to use the LaTeX tables generator?
- Enter the data. Copy cells from a spreadsheet (Excel, Google Sheets, LibreOffice Calc) or a table on a web page, click a cell and press Ctrl+V: the table grows to fit them. Or click a cell and type: typing replaces its text, while a double click or Enter edits the text that is there (Esc or a click elsewhere ends the edit). Tab and the arrow keys move to the next cell. Add and remove rows and columns with the Row and Column menus, or by right-clicking a cell. You can also import an Excel workbook or a CSV file with File / Import CSV or Excel file.
- Format it. Select cells by clicking them, by dragging over them or with Shift and the arrow keys (Ctrl+click adds a cell), then merge them, align their text, make it bold or italic and add or remove borders with the toolbar and the Table and Cell menus.
- Copy the code. The table's LaTeX code appears under the editor as you edit: click Copy to clipboard and paste it into your document. The options under the code set its style, caption, placement and width; the packages the table needs are named in a comment at its top.
To edit a table you already have in LaTeX, paste its code in File / From LaTeX code.
To write the code yourself, see our LaTeX tables cheat sheet: examples of lines, merged cells, column widths, colours, captions and long tables, each with the table that LaTeX makes from it. New to LaTeX tables? Our guide How to make a table in LaTeX builds one step by step, and Excel to LaTeX shows how to convert a table from a spreadsheet.
Standard or booktabs style?
For more professional looking tables, try the booktabs style (Style: Booktabs in the options under the code). Its tables look like those in books and scientific articles:
- no vertical rules,
- more space above and below the horizontal rules,
- a thicker rule at the top and the bottom of the table than between its rows, and no double rules.
The table's horizontal borders become the rules: the top border
\toprule, the bottom one \bottomrule and the
others \midrule (\cmidrule under some columns
only). So give the table a top and a bottom border, e.g. with
Table / Add horizontal borders.
Long text in a column
A column is as wide as its longest text. To wrap its text, give the column a
width: drag the right edge of its header above the table, or right-click the
header and choose Set column width (double-click the edge to
make the column as wide as its text again). It becomes a p{}
column of that width. To make the table as wide as the text on the page,
choose Width: Wrap to text width in the options: the
columns with a width share what the other columns leave of it (a
tabularx table). Scaling the table to the text width shrinks its
text too, which most style guides advise against.
Special characters and LaTeX commands
Characters with a special meaning in LaTeX, such as %,
&, _, # or $, are
escaped, so the cells print as typed. To write LaTeX in the cells, e.g. math
($x^2$) or \cite{key}, uncheck
Escape special characters in the options.
Convert Excel, Word or CSV to LaTeX
Select the cells in Excel, Google Sheets or LibreOffice Calc and copy them.
Click the top left cell of the editor and press Ctrl+V. The merged cells,
bold text, alignment, colours and borders come with the cells. A table
copied from Word, Google Docs or a web page pastes the same way. For a
whole file, select File / Import CSV or Excel file: it
reads .csv files and Excel workbooks (.xlsx), and
asks which sheet to import when there are several.
It also works the other way. To move a LaTeX table to Excel, paste its code in File / From LaTeX code, click a cell, press Ctrl+A to select all cells and Ctrl+C to copy them, and paste them in the spreadsheet. Or select File / Download as CSV.
Use the table in Overleaf
- Click Copy to clipboard and paste the code in your
.texfile where the table goes, between\begin{document}and\end{document}. - If the code starts with Please add the following required
packages to your document preamble, copy each
\usepackageline under it to the preamble, the part above\begin{document}. Remove the%at the start of the line.
To try the table on its own, check Complete document in the
options. The code is then a whole document with its packages. In Overleaf,
select New Project / Blank Project and replace the text of
main.tex with it. The same works in any LaTeX editor, such as
TeXstudio.
Common problems
- Undefined control sequence, at
\toprule,\multirowor\cellcolor - A package is missing. Add the
\usepackagelines from the comment at the top of the code to your preamble. - The table is at the top of the page, or on the next page
- A
tableenvironment is a float: LaTeX puts it where it fits best. The empty[]after\begin{table}uses LaTeX's default places. Write[h]in it to keep the table where it is in the text when it fits there, or[!htbp]to let LaTeX try harder. - The table is wider than the page
- Choose Width: Wrap to text width to wrap the text of long columns, or give a column a width (see Long text in a column). Rotate to a landscape page gives a wide table a page of its own.
- The table does not fit on one page
- Check Split across pages under Long table. The table continues on the next page, and it can repeat its header rows there.
Other table formats
The same editor makes tables for HTML, Markdown, plain text, Typst, MediaWiki and AsciiDoc. Open another format's page in the same browser tab, and the table is there; File / Recent tables lists the tables you made before. Our guides show how to make tables in each format by hand.