StyledTables
Apply custom formatting to tables in Julia - render HTML, docx, LaTeX and Typst
Apply custom formatting to tables in Julia - render HTML, docx, LaTeX and Typst
StyledTables provides flexible formatting functionality for tabular data. Tables can be exported as HTML, docx, LaTeX, and Typst files. It builds on data structures defined in SummaryTables.jl, with an API inspired by R's gt package.
The premise of StyledTables.jl is that your data come summarised; this package only includes formatting and styling functionality and never modifies the underlying dataset.
using StyledTables, DataFrames, Chain
using Statistics: mean
df = @chain DataFrame(StyledTables.penguins()) begin
dropmissing(_)
groupby(_, [:island, :species])
combine(_, Cols(r"bill") .=> mean => identity)
sort(_, :island)
end
tbl = StyledTable(df)
tab_rowgroup!(tbl, :island)
cols_hide!(tbl, :island)
tab_spanner!(tbl, "Bill measures" => [:bill_length_mm, :bill_depth_mm])
labels = [
:species => "Species",
:bill_length_mm => "Length",
:bill_depth_mm => "Depth"
]
cols_label!(tbl, labels)
render(tbl)| Bill measures | ||
| Species | Length | Depth |
| Biscoe | ||
| Adelie | 39 | 18.4 |
| Gentoo | 47.6 | 15 |
| Dream | ||
| Adelie | 38.5 | 18.2 |
| Chinstrap | 48.8 | 18.4 |
| Torgersen | ||
| Adelie | 39 | 18.5 |
using Pkg
Pkg.install("StyledTables")