Skip to content

Annotations

These functions annotate the table: a title and subtitle 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)

julia
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
julia
tab_header!(
    tbl::StyledTable,
    title;
    subtitle,
    align
) -> StyledTable

Add a title and optional subtitle above the column headers.

The title renders bold; the subtitle renders italic.

Arguments

  • tbl: the StyledTable to modify.

  • title: main heading text.

Keywords

  • subtitle: secondary heading text, or nothing (default).

  • align: horizontal alignment (:left, :center, :right), default :center.

Returns

tbl (modified in place).

See also: tab_spanner!, tab_sourcenote!, tab_footnote!.

Examples

julia
tbl = StyledTable(df)
tab_header!(tbl, "My Table"; subtitle = "Subtitle here")
render(tbl)

tbl = StyledTable(df)
tab_header!(tbl, "Left-aligned Title"; align = :left)
render(tbl)
source

tab_footnote!

Attach footnotes to columns, spanners, or individual body cells. An superscript marks the target; the annotation text appears below the table. For general notes, use tab_sourcenote!.

Signatures:

julia
tab_footnote!(tbl, text => col)
tab_footnote!(tbl, text => [col1, col2])
tab_footnote!(tbl, text1 => col1, text2 => col2, ...)
tab_footnote!(tbl, d::AbstractDict)
julia
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

Multiple columns with the same footnote:

julia
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)

Footnotes for different columns:

julia
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

Footnotes for spanner labels and individual cells are explained here.

StyledTables.tab_footnote! Method
julia
tab_footnote!(
    tbl::StyledTable,
    args::Pair...
) -> StyledTable

Add footnotes to the table.

Footnotes refer to specific columns. For notes not tied to any column, use tab_sourcenote!.

Arguments

  • tbl: the StyledTable to modify.

  • args: one or more text => column(s) pairs.

Returns

tbl (modified in place).

To target a spanner label or an individual cell, use SpannerTarget and CellTarget.

See also: tab_sourcenote!, tab_header!.

Examples

julia
tbl = StyledTable(df)
tab_footnote!(tbl, "PPP adjusted" => :gdp)
render(tbl)
source

tab_sourcenote!

Add a source-note line in the footer. Source notes span the full table width and are left-aligned; each call appends one.

Signature: tab_sourcenote!(tbl, text)

julia
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
julia
tab_sourcenote!(tbl::StyledTable, text) -> StyledTable

Add 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

Returns

tbl (modified in place).

See also: tab_footnote!, tab_header!.

Examples

julia
tbl = StyledTable(df)
tab_sourcenote!(tbl, "Data: World Bank Open Data")
render(tbl)
source