Learn R Programming

sumExtras (version 1.0.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, so gtsummary and plain gt tables look the same in one document. Reduces padding, adjusts font sizes, and applies JAMA journal styling.

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

  • sumExtras::use_jama_theme() for complimentary table styling

  • 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 with sumExtras for consistency
# Set JAMA theme first
use_jama_theme()

# 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