Annotations
These functions annotate the table: a title and subtitle appear at the top, footnotes and source notes at the bottom.
tab_header!
Add a title (and optional subtitle) above the column headers.
Signature: tab_header!(tbl, title; subtitle = nothing)
using StyledTables, DataFrames
df = DataFrame(country = ["US", "DE", "JP"], gdp = [25.5, 4.1, 4.2])
tbl = StyledTable(df)
tab_header!(tbl, "GDP by Country"; subtitle = "Trillions USD, 2025")
cols_label!(tbl, :country => "Country", :gdp => "GDP")
fmt_number!(tbl, :gdp; digits = 1)
render(tbl)| GDP by Country | |
| Trillions USD, 2025 | |
| Country | GDP |
| US | 25.5 |
| DE | 4.1 |
| JP | 4.2 |
StyledTables.tab_header! Function
tab_header!(
tbl::StyledTable,
title;
subtitle
) -> 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).
Returns
tbl (modified in place).
See also: tab_spanner!, tab_sourcenote!, tab_footnote!.
Examples
tbl = StyledTable(df)
tab_header!(tbl, "My Table"; subtitle = "Subtitle here")
render(tbl)tab_footnote!
Add column-annotated footnotes. An auto-numbered superscript attaches to the specified column header(s); the footnote text appears in the footnote area below the table. For general notes not attached to any column, use tab_sourcenote!.
Signatures:
tab_footnote!(tbl, text => col)tab_footnote!(tbl, text => [col1, col2])tab_footnote!(tbl, text1 => col1, text2 => col2, ...)tab_footnote!(tbl, d::AbstractDict)
tbl = StyledTable(df)
tab_header!(tbl, "GDP by Country")
tab_footnote!(tbl, "Purchasing power parity adjusted" => :gdp)
render(tbl)| GDP by Country | |
| country | gdp1 |
| US | 25.5 |
| DE | 4.1 |
| JP | 4.2 |
| 1 Purchasing power parity adjusted | |
Annotate multiple columns with the same footnote:
tbl = StyledTable(df)
tab_footnote!(tbl, "Source: World Bank (2025)" => [:country, :gdp])
render(tbl)| country1 | gdp1 |
| US | 25.5 |
| DE | 4.1 |
| JP | 4.2 |
| 1 Source: World Bank (2025) | |
Multiple independent footnotes in one call:
df2 = DataFrame(country = ["US", "DE"], gdp = [25.5, 4.1], pop = [331, 84])
tbl = StyledTable(df2)
tab_footnote!(tbl,
"Purchasing power parity adjusted" => :gdp,
"Population in millions" => :pop,
)
render(tbl)| country | gdp1 | pop2 |
| US | 25.5 | 331 |
| DE | 4.1 | 84 |
| 1 Purchasing power parity adjusted 2 Population in millions | ||
StyledTables.tab_footnote! Function
tab_footnote!(
tbl::StyledTable,
args::Pair...
) -> StyledTableAdd footnotes to the table.
Footnotes refer to specific columns. For placing general notes under the table, see tab_sourcenote!.
Arguments
tbl: theStyledTableto modify.args: one or moretext => column(s)pairs.
Returns
tbl (modified in place).
See also: tab_sourcenote!, tab_header!.
Examples
tbl = StyledTable(df)
tab_footnote!(tbl, "PPP adjusted" => :gdp)
render(tbl)tab_footnote!(
tbl::StyledTable,
d::Union{AbstractDict{<:AbstractString, <:Union{Vector{Symbol}, Vector{<:AbstractString}}}, AbstractVector{<:Pair{<:AbstractString, <:Union{Vector{Symbol}, Vector{<:AbstractString}}}}}
) -> StyledTableAdd footnotes from a dict or vector of pairs.
Arguments
tbl: theStyledTableto modify.d: anAbstractDictorAbstractVectorofPairs mapping text to column names.
Returns
tbl (modified in place).
See also: tab_spanner!, tab_header!, tab_stub!.
Examples
tbl = StyledTable(df)
tab_footnote!(tbl, Dict(
"measured each month" => [:efficacy, :safety],
"in years" => [:age])
)
render(tbl)tab_sourcenote!
Add a source-note line in the footer. Source notes span the full table width and are left-aligned. Each call appends another line.
Signature: tab_sourcenote!(tbl, text)
using SummaryTables: Multiline
note = Multiline("Data: World Bank Open Data", "Values in trillions USD")
tbl = StyledTable(df)
tab_header!(tbl, "GDP by Country")
tab_sourcenote!(tbl, note)
render(tbl)| GDP by Country | |
| country | gdp |
| US | 25.5 |
| DE | 4.1 |
| JP | 4.2 |
| Data: World Bank Open Data Values in trillions USD |
|
StyledTables.tab_sourcenote! Function
tab_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).
See also: tab_footnote!, tab_header!.
Examples
tbl = StyledTable(df)
tab_sourcenote!(tbl, "Data: World Bank Open Data")
render(tbl)