The opt_footnote_spec() function

Use a modified version of sp500 the dataset to create a gt table with row labels. We’ll add two footnotes using the tab_footnote() function. We can call opt_footnote_spec() to specify that the marks of the footnote reference should be superscripts in bold, and, the marks in the footer section should be enclosed in parentheses.

sp500 |>
  dplyr::filter(date >= "1987-10-14" & date <= "1987-10-25") |>
  dplyr::select(date, open, close, volume) |>
  dplyr::mutate(difference = close - open) |>
  dplyr::mutate(change = (close - open) / open) |>
  dplyr::mutate(day = vec_fmt_datetime(date, format = "E")) |>
  dplyr::arrange(-dplyr::row_number()) |>
  gt(rowname_col = "date") |>
  fmt_currency() |>
  fmt_number(columns = volume, suffixing = TRUE) |>
  fmt_percent(columns = change) |>
  cols_move_to_start(columns = day) |>
  cols_width(
    stub() ~ px(130),
    day ~ px(50),
    everything() ~ px(100)
  ) |>
  tab_footnote(
    footnote = "Commerce report on trade deficit.",
    locations = cells_stub(rows = 1)
  ) |>
  tab_footnote(
    footnote = "Black Monday market crash, representing the greatest
    one-day percentage decline in U.S. stock market history.",
    locations = cells_body(columns = change, rows = change < -0.15)
  ) |>
  opt_footnote_spec(spec_ref = "^xb", spec_ftr = "(x)")
day open close volume difference change
1 1987-10-14 Wed $314.52 $305.23 207.40M −$9.29 −2.95%
1987-10-15 Thu $305.21 $298.08 263.20M −$7.13 −2.34%
1987-10-16 Fri $298.08 $282.70 338.50M −$15.38 −5.16%
1987-10-19 Mon $282.70 $224.84 604.30M −$57.86 2 −20.47%
1987-10-20 Tue $225.06 $236.83 608.10M $11.77 5.23%
1987-10-21 Wed $236.83 $258.38 449.60M $21.55 9.10%
1987-10-22 Thu $258.24 $248.25 392.20M −$9.99 −3.87%
1987-10-23 Fri $248.29 $248.22 245.60M −$0.07 −0.03%
(1) Commerce report on trade deficit.
(2) Black Monday market crash, representing the greatest one-day percentage decline in U.S. stock market history.