Learn R Programming

sumExtras (version 0.3.0)

theme_gt_compact: Apply compact JAMA-style theme to gt tables

Description

Applies a compact table theme to gt tables that matches the 'jama' theme from gtsummary. This ensures visual consistency when mixing gtsummary tables (using theme_gtsummary_compact("jama")) with regular gt tables in the same document. The theme reduces padding, adjusts font sizes, and applies JAMA journal styling conventions.

Usage

theme_gt_compact(tbl)

Value

A gt table object with compact JAMA-style formatting applied

Arguments

tbl

A gt table object created with gt::gt()

Details

This function replicates the visual appearance of gtsummary::theme_gtsummary_compact("jama") for use with regular gt tables. Key styling includes:

  • Reduced font size (13px) for compact appearance

  • Minimal padding (1px) on all row types

  • Bold column headers and table titles

  • Hidden top and bottom table borders

  • Consistent spacing that matches JAMA journal standards

See Also

  • gtsummary::theme_gtsummary_compact() for gtsummary table themes

  • gtsummary::set_gtsummary_theme() for setting global gtsummary themes

  • gt::tab_options() for additional gt table styling options

Examples

Run this code
# Basic usage with a data frame
mtcars |>
  head() |>
  gt::gt() |>
  theme_gt_compact()

# Combine with other gt functions
mtcars |>
  head() |>
  gt::gt() |>
  gt::tab_header(title = "Vehicle Data") |>
  theme_gt_compact()

# Use alongside gtsummary tables for consistency
# Set gtsummary theme first
gtsummary::set_gtsummary_theme(gtsummary::theme_gtsummary_compact("jama"))

# Then both tables will have matching appearance
summary_table <- gtsummary::trial |>
  gtsummary::tbl_summary()

data_table <- gtsummary::trial |>
  head() |>
  gt::gt() |>
  theme_gt_compact()

Run the code above in your browser using DataLab