LaTeX Table Generator
Type into the grid and the tabular source is written beside it, row by row, with every cell escaped for LaTeX text mode. The ten characters LaTeX reserves are the reason this page exists: an ampersand that reaches the source unescaped opens a column the table was never declared with, and a percent sign comments out the rest of the line, which takes the row terminator with it and pulls the next row onto the end of this one. Both of those change the table without a word of warning, so all ten are escaped in a single pass over the cell, which is also why the braces that \textbackslash{} carries are never escaped a second time. A formula is the one thing that has to stay raw, and it is opt in twice over: choose Raw math, then mark the span with dollar signs inside the cell, and the text around the span is still escaped. With that mode off a dollar sign is a dollar sign, which is what a price column needs. Rows pasted from a spreadsheet arrive as tab separated text, and a row that arrives short is filled out on the right so its values stay under the headings they were pasted under, with the page saying how many rows it padded. Booktabs rules write \toprule, \midrule and \bottomrule and the page names \usepackage{booktabs} beside the result; the line style writes \hline and vertical bars instead, and needs nothing added. The preview under the source is the same grid drawn as a table, and the grid holds 200 rows by 50 columns.
C1 l | C2 r | C3 l | ||
|---|---|---|---|---|
| H | ||||
| 1 | ||||
| 2 |
\begin{tabular}{lrl}
\toprule
Sample & Yield \% & Note \\
\midrule
A\_1 & 91.4 & 50\% run \\
B\_2 & 88.0 & re-run \& held \\
\bottomrule
\end{tabular}- Rows
- 3
- Columns
- 3
- Alignment
- l r l
- Rules
- booktabs
3 columns by 3 rows, 8 lines of LaTeX, 5 characters escaped.
Needs \usepackage{booktabs} in the preamble. The buttons beside a row and above a column move it with every value in it, and the alignment moves with the column. Past 1,000 cells the grid is edited as text instead, because a page of that many boxes is not an editor.
Preview
The same grid, drawn as a table. Cell text is drawn as text, so a marked math span shows here as the characters you typed rather than as a typeset formula.
| Sample | Yield % | Note |
|---|---|---|
| A_1 | 91.4 | 50% run |
| B_2 | 88.0 | re-run & held |
- escaped as R\&D 50\% a\_b \#3, 2 columns unchanged
- $\sigma^2$ is copied through raw
- padded to 3 cells and flagged, never shifted
Common questions
- How do I escape special characters in a LaTeX table?
- Type them into the cell and this page escapes them for you. LaTeX reserves ten characters in text mode, and every one of them is written out: a backslash becomes \textbackslash{}, an ampersand becomes \&, a percent sign becomes \%, a dollar sign becomes \$, a hash becomes \#, an underscore becomes \_, a left brace becomes \{, a right brace becomes \}, a tilde becomes \textasciitilde{} and a caret becomes \textasciicircum{}. Two of those are the ones that bite: an unescaped ampersand opens a column the tabular was never declared with, and an unescaped percent sign comments out everything after it on that line, including the row terminator. A cell reading re-run & held comes out as re-run \& held, and its row still has the same number of column breaks as every other row. The cell is escaped in a single pass, so the empty braces that \textbackslash{}, \textasciitilde{} and \textasciicircum{} carry are left alone rather than escaped again, which is the mistake that prints a stray brace in the finished table. A less-than or greater-than sign is not one of the ten and is passed through as you typed it; under the default font encoding LaTeX prints those two as inverted punctuation, so load fontenc with the T1 option if your table uses them.
- Can I paste a table from Excel or Google Sheets?
- Yes, in the Text view. Cells copied out of a spreadsheet arrive as tab separated rows and the grid follows as you paste: Auto works out whether it is looking at tabs or commas, and the Tab and Comma buttons override the guess when it is wrong. A value wrapped in double quotes keeps its commas, its line breaks and any quote written twice inside it, which is how a spreadsheet exports a cell containing one. Nothing changes silently: a row that arrives with fewer values than the widest row is filled out on the right with empty cells and the page says how many rows it padded, and blank lines are skipped and counted. Copy TSV hands the grid back in the same form, so it goes back into a spreadsheet the way it came out.
- Should I use booktabs or hline rules?
- Booktabs is the default here and writes \toprule, a \midrule under the header row and \bottomrule at the end, with no vertical bars, which is what the package's own guidance asks for in a formal table. It is the one choice that needs something in your preamble, so the page names \usepackage{booktabs} beside the result and stops naming it as soon as you switch away. Lines writes the classic \hline above, below and between every row, and puts bars in the column spec, so a two column table opens with \begin{tabular}{|l|r|}. None writes the rows and the tabular environment and nothing else. Whichever you choose, the Rules cell in the readout says which one is in the source you are about to copy.
- How do I put a formula or a dollar amount in a cell?
- A dollar sign is text until you say otherwise. With the default Text setting, a cell holding a price is escaped and reaches your document as the amount you typed. Switch the dollar sign control to Raw math and a span you mark with dollar signs inside a cell is copied through exactly as typed, while the text around it is still escaped: a cell reading the words before a marked span, the span, and a percent sign after it comes out with the span raw and the percent sign escaped. Marking is the opt in, so a cell that holds no dollar signs is escaped as text even in that mode. A cell with an odd number of dollar signs is refused by row and column, because one span never closes and guessing where you meant it to end would be a worse answer than saying so.
- How do I add a caption and a label to the table?
- Wrap what you copy in a table environment: \begin{table}[ht] and \centering, then \caption{} and \label{} with your own text in the braces, then the tabular block this page writes, then \end{table}. Most styles put a table's caption above the table, which is why the caption line goes before the tabular block rather than after it. This page writes the tabular block and nothing around it on purpose: the float, where it is allowed to land and what it is called belong to your document, and a generator that guesses them hands you lines to delete every time.
- How large can the table be, and does anything leave my browser?
- The grid holds 200 rows by 50 columns, the header row counted among the rows. Past that nothing is cut down quietly: a paste of 201 rows is refused with its own numbers and the limit beside them, so you can split it or paste the rows you need. Up to a thousand cells the grid is one text box per cell; past that the editor is the text view instead, because a page holding that many boxes is not one you can type in. Nothing is sent anywhere and there is no account: the source is built in your own browser, the draft is kept in this browser alone so it is still there when you come back, and the Start over button above the tool forgets it. Storage blocked or a private window changes nothing except that it does not remember.
- What happens to a line break inside a cell?
- It becomes a single space, and the page counts it. An l, c or r column is one line by definition: a line break inside such a cell is whitespace at best, and two of them in a row would, if they reached the source, end the paragraph in LaTeX and stop its run with an error about a paragraph ending before the row was complete. Folding the break to a space keeps the row intact, and the status line says how many breaks were folded so nothing happens out of sight. If you need text on two lines inside one cell, the shortest route is to split it into two rows, or to change that column to a paragraph column by hand after copying the source.
- Does the preview show what the finished table will look like?
- It shows the same grid, drawn as an HTML table with the alignment you chose, so you can read the values in place while you edit them. It is not a rendering of LaTeX: a marked math span shows as the characters you typed, and the rules you chose are described in the readout rather than drawn. What the preview guarantees is that the source and the table on screen come from one grid, so a cell you can see is a cell the source carries, escaped.
Every cell is escaped for LaTeX text mode unless you mark it as math yourself, so an ampersand becomes a character rather than a column break and a percent sign does not comment out the rest of the line. The HTML preview is built from the same grid as the source, so what you read is what you copy.