Write tabular data from Julia in LaTeX format.
37 Stars
Updated Last
1 Year Ago
Started In
January 2018


lifecycle build

Write tabular data from Julia in LaTeX format.

This is a very thin wrapper, basically for avoiding some loops and repeatedly used strings. It assumes that you know how the LaTeX tabular environment works, and you have formatted the cells to strings if you want anything fancy like rounding or alignment on the decimal dot.

This is how it works:

using LaTeXTabulars
using LaTeXStrings               # not a dependency, but works nicely
               [L"\alpha", L"\beta", "sum"],
               [1, 2, 3],
               Rule(),           # a nice \hline to make it ugly
               [4.0 "5" "six";   # a matrix
                7 8 9],
               CMidRule(1, 2),
               [MultiColumn(2, :c, "centered")], # ragged!

will write something like

$\alpha$ & $\beta$ & sum \\
1 & 2 & 3 \\
4.0 & 5 & six \\
7 & 8 & 9 \\
\multicolumn{2}{c}{centered} \\

to /tmp/table.tex.

Note that the position specifier lcl is not checked for valid syntax or consitency with the contents, just emitted as is, allowing the use of dcolumn or similar, and the number of cells in each line is not checked for consistency. This means that the usual LaTeX rules apply: fewer cells than position specifiers gives you a ragged table, more cells and LaTeX will complain about having to change & to \\.

See ?latex_tabular for the documentation of the syntax, and the unit tests for examples.

Rule types in booktabs are supported. Vertical rules of any kind are not explicitly supported and it would be difficult to convince me to add them. The documentation of booktabs should explain why. That said, if you insist, you can use a cell like \vline text.

The other tabular type currently implemented is LongTable. The code is generic, so other tabular-like types can be easily added, just open an issue.

Used By Packages