Skip to contents

Increase or decrease the horizontal padding throughout all locations of a gt table by use of a scale factor, which here is defined by a real number between 0 and 3. This function serves as a shortcut for setting the following eight options in tab_options():

  • heading.padding.horizontal

  • column_labels.padding.horizontal

  • data_row.padding.horizontal

  • row_group.padding.horizontal

  • summary_row.padding.horizontal

  • grand_summary_row.padding.horizontal

  • footnotes.padding.horizontal

  • source_notes.padding.horizontal

Usage

opt_horizontal_padding(data, scale = 1)

Arguments

data

A table object that is created using the gt() function.

scale

A scale factor by which the horizontal padding will be adjusted. Must be a number between 0 and 3.

Value

An object of class gt_tbl.

Examples

Use exibble to create a gt table with a number of table parts added. Expand the horizontal padding across the entire table with opt_horizontal_padding().

exibble %>%
  gt(rowname_col = "row", groupname_col = "group") %>%
  summary_rows(
    groups = "grp_a",
    columns = c(num, currency),
    fns = list(
      min = ~min(., na.rm = TRUE),
      max = ~max(., na.rm = TRUE)
    )) %>%
  grand_summary_rows(
    columns = currency,
    fns = list(
      total = ~sum(., na.rm = TRUE)
    )) %>%
  tab_source_note(source_note = "This is a source note.") %>%
  tab_footnote(
    footnote = "This is a footnote.",
    locations = cells_body(columns = 1, rows = 1)
  ) %>%
  tab_header(
    title = "The title of the table",
    subtitle = "The table's subtitle"
  ) %>%
  opt_horizontal_padding(scale = 3)

Function ID

9-5