Prework
Seems potentially related to #1907
Question
I generally using gt in combination with patchwork to output chart/table combos. The development of as_gtable gave me far more flexibility to craft the output (from the former roundtrip to .png. Thanks!!!). I have used table.width = pct(100) to ensure that that table output spans the width of the container, while using the cols_width to apportion individual columns.
Might there be another manner to achieve the objective of forcing the table to fit the output container while maintaining relative spacing across columns?
Seems as_gtable drops the table.width requirement (without as_gtable, table.width and cols_width both retained):
library(gt)
library(gtExtras)
library(tidyverse)
start_date <- "2010-06-07"
end_date <- "2010-06-08"
### no as_gtable
#### table.width not assigned
#### works as expected
sp_tab <-
sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date >= start_date & date <= end_date) %>%
gt() %>%
cols_width(date ~ pct(50))
gt_reprex_image(sp_tab)

#### table.width assigned
#### works as expected
sp_tab <-
sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date >= start_date & date <= end_date) %>%
gt() %>%
tab_options(table.width = pct(100)) %>%
cols_width(date ~ pct(50))
gt_reprex_image(sp_tab)

### w/ as_gtable
#### table.width not assigned
#### works as expected
sp_tab <-
sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date >= start_date & date <= end_date) %>%
gt() %>%
cols_width(date ~ pct(50)) %>%
as_gtable(plot = TRUE)

#### table.width assigned
#### does not work as expected
sp_tab <-
sp500 %>%
select(-c(volume, adj_close)) %>%
dplyr::filter(date >= start_date & date <= end_date) %>%
gt() %>%
tab_options(table.width = pct(100)) %>%
cols_width(date ~ pct(50)) %>%
as_gtable(plot = TRUE)

Created on 2024-11-14 with reprex v2.1.1
Prework
Seems potentially related to #1907
Question
I generally using gt in combination with patchwork to output chart/table combos. The development of as_gtable gave me far more flexibility to craft the output (from the former roundtrip to .png. Thanks!!!). I have used table.width = pct(100) to ensure that that table output spans the width of the container, while using the cols_width to apportion individual columns.
Might there be another manner to achieve the objective of forcing the table to fit the output container while maintaining relative spacing across columns?
Seems as_gtable drops the table.width requirement (without as_gtable, table.width and cols_width both retained):
Created on 2024-11-14 with reprex v2.1.1