LaTeX table generator for papers, theses and reports
Writing a tabular environment by hand is error-prone: an unescaped percent sign comments out the rest of the line, a missing ampersand shifts every column, and a stray underscore stops compilation. This LaTeX table generator takes the numbers you already have in a CSV file or spreadsheet and writes a complete, compilable table float with caption, label and escaped cell contents.
Example
Method,Error (%),Cost ($),Notes
k_means,4.2,120,uses {init}
Baseline #2,7.9,80,~ approx & fast
With the caption Results & costs, the label tab:results and default options:
\begin{table}[htbp]
\centering
\caption{Results \& costs}
\label{tab:results}
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Method} & \textbf{Error (\%)} & \textbf{Cost (\$)} & \textbf{Notes} \\
\hline
k\_means & 4.2 & 120 & uses \{init\} \\
Baseline \#2 & 7.9 & 80 & \textasciitilde{} approx \& fast \\
\hline
\end{tabular}
\end{table}
Every character with a special meaning in LaTeX was escaped, in the caption as well as in the cells.
Special characters that are escaped
| In your data | In the LaTeX output |
|---|---|
& % $ # _ { } | \& \% \$ \# \_ \{ \} |
~ | \textasciitilde{} |
^ | \textasciicircum{} |
| backslash | \textbackslash{} |
| line break inside a cell | a space |
Because backslashes are escaped too, you cannot type LaTeX commands such as math into the data and have them pass through. Add math, \multicolumn or colour commands in the .tex file after generating the table.
Options explained
- Caption and Label – the caption is placed above the tabular, as most style guides expect for tables. The label is cleaned to letters, digits and
: . - _, sotab:my results!becomestab:myresults. Refer to it with\ref{tab:results}. - Alignment –
l,corrfor every column. Right alignment suits numeric tables; change individual letters in the column spec afterwards if you need a mix. - Vertical borders – on by default: a column spec like
|l|l|plus\hlineabove and below the header and at the end. Untick it for a spec such asl lwith no rules at all. - booktabs style – replaces the grid with
\toprule,\midruleand\bottomrule, and turns vertical borders off, as the booktabs package recommends. - Bold header – wraps each header cell in
\textbf{}. - First row is header – untick it for data without column names; no header row or middle rule is written.
booktabs output
Many journals and thesis templates prefer booktabs tables without vertical lines. With booktabs style ticked, centered alignment and no bold header:
% requires \usepackage{booktabs}
\begin{table}[htbp]
\centering
\begin{tabular}{c c c c}
\toprule
Method & Error (\%) & Cost (\$) & Notes \\
\midrule
k\_means & 4.2 & 120 & uses \{init\} \\
Baseline \#2 & 7.9 & 80 & \textasciitilde{} approx \& fast \\
\bottomrule
\end{tabular}
\end{table}
The comment on the first line is a reminder to add \usepackage{booktabs} to your preamble; without it the rule commands are undefined.
How the float is set up
The generator wraps the tabular in a table environment with the placement specifier [htbp], which lets LaTeX put the table here, at the top or bottom of a page, or on a separate float page, whichever fits best. \centering centers it horizontally without adding the extra vertical space that a center environment would. If you need the table exactly at this spot, change the specifier to [h!] or use the float package's [H].
Using a tab: prefix in the label is a common convention that keeps table labels apart from figures (fig:) and sections (sec:) when you reference them.
Tips
- Numbers are read as numbers, so
4.20is written as4.2. If trailing zeros matter, supply the data as JSON with quoted strings, or use the siunitx package to format the column. - Wide tables may overflow the text width. Reduce the font with
\smallinside the table environment or wrap the tabular in\resizeboxfrom the graphicx package. - Very long tables that span pages need the longtable package; the generated rows can be reused inside its environment.
The same input can become a Markdown table for a README or an HTML table via Table to HTML. To inspect a CSV before converting, use the CSV viewer.
Privacy
The LaTeX code is produced in your browser, so unpublished results stay on your computer. Only Load URL and Save & Share use our server.