API
Complete API reference for StyledTables.jl. All exported symbols are listed below, grouped by kind.
StyledTables.CellTarget Type
struct CellTargetIdentifies a single body cell as the target of a footnote! call.
row::Union{Int64, Stub}: Data row index (Int) or a stub-column lookup key (Stub).col::Symbol: Column name.
StyledTables.CellTarget Method
CellTarget(row, col)Construct a CellTarget.
CellTarget(3, :gdp)targets row 3 of the data (1-based), column:gdp.CellTarget(Stub("Alice"), :gdp)targets the row(s) where the stub column equals"Alice"in column:gdp. Only works ifstub!was called before.
StyledTables.SpannerTarget Type
struct SpannerTargetIdentifies a spanner label as the target of a footnote! call.
label::Any: The spanner label to match (compared with==).level::Union{Nothing, Int64}: Restrict the match to this spanner level, ornothingto match all levels.
StyledTables.SpannerTarget Method
SpannerTarget(label; level = nothing)Construct a SpannerTarget.
label may any value that can be passed to spanner!.
level restricts the match to a specific spanner row. When nothing (default), all spanners whose label matches are annotated.
StyledTables.Stub Type
struct StubA wrapper that signals a stub-column lookup when used as the row argument of CellTarget.
value::Any: The value to look up in the stub column.
StyledTables.StyledTable Type
mutable struct StyledTableContains table build specifications for the DataFrame to be rendered.
Construct with StyledTable, apply modifier functions, then call render:
tbl = StyledTable(df)
relabel!(tbl, :x => "X")
header!(tbl, "Title")
render(tbl)data::DataFrame: Source data.col_labels::Dict{Symbol, Any}: Display labels keyed by column name.col_alignments::Dict{Symbol, Symbol}: Horizontal alignment (:left,:center,:right) keyed by column name.spanners::Vector{StyledTables.Spanner}: Spanner header definitions.rowgroup_col::Union{Nothing, Symbol}: Column used for row grouping, ornothing.rowgroup_indent_pt::Float64: Left indent applied to data rows inside a group (points).rowgroup_full_width::Bool: Whentrue, row-group label rows span the full table width instead of the first cell only.stub_col::Union{Nothing, Symbol}: Column designated as the stub (row-label column), ornothing.header::Union{Nothing, StyledTables.TableHeader}: Title/subtitle definition, ornothing.footnotes::Vector{Any}: Table-level footnote texts.col_formatters::Dict{Symbol, Vector{AbstractFormatter}}: Per-column formatter stacks, applied in call order.col_styles::Dict{Symbol, StyledTables.ColStyleOverride}: Per-column inline style overrides.col_style_fns::Dict{Symbol, Function}: Per-column conditional style functionsf(raw_value) -> Union{Nothing, NamedTuple}.col_footnotes::Dict{Symbol, Any}: Per-column footnote annotations.spanner_footnotes::Vector{Pair{SpannerTarget, Any}}: Per-spanner footnote entries:SpannerTarget => annotation.cell_footnotes::Dict{Tuple{Int64, Symbol}, Any}: Per-cell footnote annotations keyed by(data_row_index, col_symbol).hidden_cols::Set{Symbol}: Columns excluded from the rendered output.stubhead_label::Any: Label for the stub column header, ornothing.sourcenotes::Vector{Any}: Source-note lines appended below the table body.postprocessors::Vector{Any}: SummaryTables postprocessors applied during rendering.round_digits::Union{Nothing, Int64}: Digits to round to, ornothing(SummaryTables defaults to 3).round_mode::Union{Nothing, Symbol}: Global rounding mode (:auto,:digits,:sigdigits), ornothing.trailing_zeros::Union{Nothing, Bool}:trueto pad with trailing zeros when rounding;nothingdefers to SummaryTables.
StyledTables.StyledTable Method
StyledTable(data) -> StyledTableWrap a DataFrame (or any Tables.jl-compatible table) in a StyledTable.
Returns a StyledTable with default settings. Apply modifier functions and call render to produce a SummaryTables.Table.
Arguments
data: aDataFrameor any Tables.jl-compatible table.
Returns
A StyledTable.
See also: render, relabel!, header!.
Examples
tbl = StyledTable(df)
header!(tbl, "My Table")
render(tbl)StyledTables.align! Method
align!(
tbl::StyledTable,
d::Union{AbstractDict{Symbol, Symbol}, AbstractDict{<:AbstractString, Symbol}, AbstractVector{<:Pair{Symbol, Symbol}}, AbstractVector{<:Pair{<:AbstractString, Symbol}}, AbstractVector{<:Pair{Vector{Symbol}, Symbol}}, AbstractVector{<:Pair{<:AbstractVector{<:AbstractString}, Symbol}}}
) -> StyledTableSet alignment from a dict or vector of col => halign pairs.
Arguments
tbl: theStyledTableto modify.d: anAbstractDictorAbstractVectorofcol => halignpairs.
Returns
tbl (modified in place).
Examples
tbl = StyledTable(df)
align!(tbl, Dict(:x => :right, :y => :center))
render(tbl)StyledTables.align! Method
align!(tbl::StyledTable, args::Pair...) -> StyledTableSet horizontal alignment for one or more columns.
Each argument is a col => halign pair, where col is a Symbol matching a column name and halign is one of :left, :center, or :right.
Arguments
tbl: theStyledTableto modify.args: one or morecol => halignpairs.
Returns
tbl (modified in place).
Examples
tbl = StyledTable(df)
align!(tbl, :x => :right, :y => :center)
render(tbl)StyledTables.footnote! Method
footnote!(
tbl::StyledTable,
d::Union{AbstractDict{<:Union{Vector{Symbol}, Vector{<:AbstractString}}, <:AbstractString}, AbstractVector{<:Pair{<:Union{Vector{Symbol}, Vector{<:AbstractString}}, <:AbstractString}}}
) -> StyledTableAdd footnotes from a dict or vector of pairs.
Arguments
tbl: theStyledTableto modify.d: anAbstractDictorAbstractVectorofPairs mapping column names to text.
Returns
tbl (modified in place).
See also: spanner!, header!, stub!.
Examples
tbl = StyledTable(df)
footnote!(tbl, Dict(
[:efficacy, :safety] => "measured each month",
[:age] => "in years")
)
render(tbl)StyledTables.format! Method
format!(formatter, tbl, cols...)
format!(formatter, tbl, cols::AbstractVector)Append formatter to the format stack for each column in cols.
formatter may be any AbstractFormatter or a bare callable (automatically wrapped in FunctionFormatter).
Formatters are applied in call order at render time: the first format! call runs first on the raw value. Stack MissingFormatter last to intercept any missing values that remain after earlier formatters.
Examples
tbl = StyledTable(df)
format!(NumberFormatter(digits = 3), tbl, :x, :y)
format!(MissingFormatter("—"), tbl, :x, :y)
render(tbl)StyledTables.header! Method
header!(
tbl::StyledTable,
title;
subtitle,
align
) -> StyledTableAdd a title and optional subtitle above the column headers.
The title renders bold; the subtitle renders italic.
Arguments
tbl: theStyledTableto modify.title: main heading text.
Keywords
subtitle: secondary heading text, ornothing(default).align: horizontal alignment (:left,:center,:right), default:center.
Returns
tbl (modified in place).
See also: spanner!, sourcenote!, footnote!.
Examples
tbl = StyledTable(df)
header!(tbl, "My Table"; subtitle = "Subtitle here")
render(tbl)
tbl = StyledTable(df)
header!(tbl, "Left-aligned Title"; align = :left)
render(tbl)StyledTables.hide! Method
hide!(tbl::StyledTable, cols::Symbol...) -> StyledTableRemove columns from the rendered output without modifying the DataFrame.
Hidden columns remain accessible for grouping or formatting, but do not appear in the rendered table. Commonly paired with rowgroup!.
Arguments
tbl: theStyledTableto modify.cols: one or more column names to hide.
Returns
tbl (modified in place).
See also: rowgroup!.
Examples
tbl = StyledTable(df)
rowgroup!(tbl, :group)
hide!(tbl, :group)
render(tbl)StyledTables.relabel! Method
relabel!(
tbl::StyledTable,
d::Union{AbstractDict{Symbol, Symbol}, AbstractDict{<:AbstractString, <:AbstractString}, AbstractDict{<:AbstractString, Symbol}, AbstractDict{Symbol, <:AbstractString}, AbstractVector{<:Pair{Symbol, Symbol}}, AbstractVector{<:Pair{<:AbstractString, <:AbstractString}}, AbstractVector{<:Pair{<:AbstractString, Symbol}}}
) -> StyledTableRename columns using a dict or vector of pairs.
Arguments
tbl: theStyledTableto modify.d: aDictor vector ofcol => labelpairs specifying columns and their labels.
Returns
tbl (modified in place).
Examples
label_dict = Dict(:bmi => "BMI (kg/m²)", :sbp => "Systolic BP")
tbl = StyledTable(df)
relabel!(tbl, label_dict)
render(tbl)StyledTables.render Method
render(tbl::StyledTable) -> TableConvert a StyledTable into a renderable SummaryTables.Table.
Applies all registered modifiers (labels, spanners, formatters, styles, row groups) and assembles the cell matrix. The result renders to HTML, LaTeX, and Typst.
In interactive contexts, render is optional: StyledTable defines Base.show methods that call it automatically.
Arguments
tbl: aStyledTableconfigured with modifier functions.
Returns
A SummaryTables.Table (a Matrix{Cell} with header/footer metadata).
See also: StyledTable, header!, relabel!.
Examples
using StyledTables, DataFrames
df = DataFrame(a = [1, 2], b = ["x", "y"])
tbl = StyledTable(df)
relabel!(tbl, :a => "A", :b => "B")
render(tbl)StyledTables.rowgroup! Method
rowgroup!(
tbl::StyledTable,
col::Symbol;
indent_pt,
full_width
) -> StyledTableGroup rows by distinct values in a column.
A bold group-label row precedes each new group value. Data rows are indented by indent_pt points. Hide the grouping column afterwards with hide!.
Arguments
tbl: theStyledTableto modify.col: column whose distinct values define the groups.
Keywords
indent_pt: left indent for data rows within a group (default12).full_width: whether group-label rows span the entire table width (defaultfalse).
Returns
tbl (modified in place).
Examples
tbl = StyledTable(df)
rowgroup!(tbl, :category)
hide!(tbl, :category)
render(tbl)StyledTables.sourcenote! Method
sourcenote!(tbl::StyledTable, text) -> StyledTableAdd a source-note line in the table footer.
Source notes span the full table width and are left-aligned. Each call appends another line.
Arguments
tbl: theStyledTableto modify.text: source note text.
Returns
tbl (modified in place).
Examples
tbl = StyledTable(df)
sourcenote!(tbl, "Data: World Bank Open Data")
render(tbl)StyledTables.spanner! Method
spanner!(
tbl::StyledTable,
d::Union{AbstractDict{Vector{Symbol}, Symbol}, AbstractDict{Symbol, Symbol}, AbstractDict{Symbol, Multiline}, AbstractDict{<:AbstractVector{<:AbstractString}, <:AbstractString}, AbstractDict{<:AbstractVector{<:AbstractString}, Symbol}, AbstractDict{Vector{Symbol}, <:AbstractString}, AbstractDict{<:AbstractString, <:AbstractString}, AbstractDict{<:AbstractString, Symbol}, AbstractDict{Symbol, <:AbstractString}, AbstractDict{<:AbstractString, Multiline}, AbstractVector{<:Pair{<:AbstractVector{<:AbstractString}, <:AbstractString}}, AbstractVector{<:Pair{Vector{Symbol}, Symbol}}, AbstractVector{<:Pair{<:AbstractVector{<:AbstractString}, Symbol}}, AbstractVector{<:Pair{Vector{Symbol}, <:AbstractString}}, AbstractVector{<:Pair{<:AbstractString, <:AbstractString}}, AbstractVector{<:Pair{<:AbstractString, Symbol}}, AbstractVector{<:Pair{Symbol, <:AbstractString}}, AbstractVector{<:Pair{Symbol, Symbol}}, AbstractVector{<:Pair{Symbol, Multiline}}, AbstractVector{<:Pair{<:AbstractString, Multiline}}};
level
) -> StyledTableAdd spanning headers from a dict or vector of pairs.
Arguments
tbl: theStyledTableto modify.d: anAbstractDictorAbstractVectorpairing column names to spanner labels.level: the spanner row applied to every entry ind(default1).
Returns
tbl (modified in place).
See also: spanner!, header!, stub!.
Examples
tbl = StyledTable(df)
spanner!(tbl, Dict(
[:efficacy, :safety] => "Outcomes",
[:age, :sex] => "Demographics")
)
render(tbl)StyledTables.stub! Method
stub!(tbl::StyledTable, col::Symbol) -> StyledTableMark a column as the stub (row-label column).
The stub header is not bolded. Use stubhead! to label it.
Arguments
tbl: theStyledTableto modify.col: name of the column to use as the stub.
Returns
tbl (modified in place).
See also: stubhead!, rowgroup!.
Examples
tbl = StyledTable(df)
stub!(tbl, :drug)
render(tbl)StyledTables.stubhead! Method
stubhead!(tbl::StyledTable, label) -> StyledTableSet the stub column header label.
Requires a prior call to stub!.
Arguments
tbl: theStyledTableto modify.label: display text for the stub header cell.
Returns
tbl (modified in place).
See also: stub!.
Examples
tbl = StyledTable(df)
stub!(tbl, :drug)
stubhead!(tbl, "Drug Name")
render(tbl)