DEV Community

Cover image for How to Export a Table to LaTeX: Complete Guide
Olayiwola Akinnagbe
Olayiwola Akinnagbe

Posted on • Originally published at tablesmit.com

How to Export a Table to LaTeX: Complete Guide

The standard options for getting a table into LaTeX are: write the
tabular syntax by hand, use Tables Generator, or build it in Excel
and use a converter. All three have the same problem: the output
requires manual editing before it is actually usable.

Writing tabular by hand is slow. You count ampersands, check that
every row is consistent, escape special characters manually, and
debug alignment by compiling. For a ten-column table with twenty
rows this takes longer than it should.

Tables Generator is faster but the column alignment control is
limited. It does not derive alignment from data type: you set it
manually for each column.

Excel converters are inconsistent. The column spec is often wrong
and special character escaping is unreliable.

Tablesmit solves this by deriving the LaTeX output from the visual
table you build. Here is exactly what the export generates:

Column alignment from column type: Text gets l, Number and
Currency and Percentage get r. You do not set this manually.

Special character escaping: %, $, &, _, ^, {, } are all escaped
in the output. If your data contains any of these, the export
handles it.

Caption: your caption field maps to \caption{}. It appears in the
right position in the generated block.

The complete output:

\begin{table}[h]
\centering
\caption{Your caption here}
\begin{tabular}{l r r}
\hline
Label & Value & Change \
\hline
Revenue & 1,240 & 12.4\% \
Expenses & 980 & 8.1\% \
\hline
\end{tabular}
\end{table}

Paste it straight into your .tex file.

Free, no account, MIT licensed. tablesmit.com


This post originally appeared on the Tablesmit Blog at tablesmit.com/blog/how-to-export-table-to-latex. Tablesmit is a free, open source table builder. Export to PDF, Excel, LaTeX, CSV, PNG. No account required. Try it at tablesmit.com.

Top comments (0)