How to use the table generator
Click a cell and type. Tab and Enter move between cells, and pressing Enter on the last row adds a new one. Use the size button to pick the number of rows and columns, or add them one at a time.
To bring in data, copy a range in Excel, Google Sheets or Numbers and paste it into any cell: the grid fills in and LaTeX special characters like % and & are escaped for you. To edit a table you already have, choose Paste LaTeX and drop in its code.
Pick an alignment per column, a border style, and an optional caption and label. The LaTeX updates as you go; copy it into your document, or open it as a new Samskrift project to compile it straight away.
How tables work in LaTeX
A LaTeX table is a tabular environment. Its argument lists one letter per column: l, c or r for left, centred or right-aligned. Cells are separated by & and every row ends with \\.
Wrapping the tabular in a table environment makes it a float: LaTeX places it where it fits best, and you can give it a numbered caption and a label to refer to.
\begin{table}[ht]
\centering
\begin{tabular}{lcr}
Left & Centre & Right \\
a & b & c \\
\end{tabular}
\caption{A minimal table.}
\label{tab:minimal}
\end{table}Why booktabs looks better
Professional typesetting avoids vertical lines and uses three horizontal rules of different weights: a heavy rule on top, a light one under the header and a heavy one at the bottom. The booktabs package provides exactly these as \toprule, \midrule and \bottomrule, with better spacing around them than \hline.
That is why the generator uses booktabs by default. Add \usepackage{booktabs} to your preamble once. If you need a full grid instead, choose All borders and no extra package is required.
\usepackage{booktabs} % in the preamble
\begin{tabular}{lrr}
\toprule
Setup & Time & Errors \\
\midrule
Before & 21 & 14 \\
After & 9 & 0 \\
\bottomrule
\end{tabular}Captions, labels and placement
Put \label after \caption, then write Table~\ref{tab:results} in your text and LaTeX fills in the number. The optional argument of table suggests where the float may go: h here, t top of a page, b bottom, p a page of floats. [htbp] gives LaTeX the most freedom and avoids warnings.
Tables in academic papers usually carry their caption above the table; switch Caption above on if your style guide asks for it.
Merging cells
\multicolumn{n}{c}{Text} spans a cell across n columns, and \multirow from the multirow package spans rows. The generator keeps merged cells intact when you paste an existing table in, so you can still edit the rest of the grid.
\begin{tabular}{lcc}
\toprule
& \multicolumn{2}{c}{Score} \\
\cmidrule(lr){2-3}
Method & Train & Test \\
\midrule
A & 0.91 & 0.88 \\
\bottomrule
\end{tabular}When the table is too wide
Shorten headers first, then try a smaller font with \small inside the table. For text-heavy columns, tabularx stretches the table to the line width and wraps long cells; as a last resort \resizebox{\linewidth}{!}{...} from graphicx scales the whole table.
Questions
- Can I paste a table from Excel or Google Sheets?
- Yes. Copy the cells in your spreadsheet and paste into any cell of the grid. Rows and columns are filled in, and characters that mean something in LaTeX (
%, &, $, #, _) are escaped. - Can I edit a LaTeX table I already have?
- Yes. Choose Paste LaTeX, drop in the table's code (with or without the surrounding
table environment) and it opens in the grid. Column alignment, rules, captions, labels and merged cells are kept. - Which packages do I need?
- The default style needs
\usepackage{booktabs}. Tables with All borders, Horizontal lines or No lines compile with plain LaTeX. If your cells use maths symbols from amssymb, include that too. - Is my table sent anywhere?
- No. The generator runs entirely in your browser. Nothing leaves your computer unless you choose Open in Samskrift, which creates a project in your own account.