jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

Linking a two-column layout and adding spanning elements #130

Closed nvietto closed 5 months ago

nvietto commented 5 months ago

Proposal

This is a great package, thanks for all your hard work! While building a table using the two-column layout feature (tutorial here: https://jthomasmock.github.io/gtExtras/reference/gt_two_column_layout.html#figures), I noticed the output appears disjointed (see attached image). It would be fantastic if the tables could link seamlessly and allow for spanning elements like titles across both columns.

Code

library(gt)
library(gtExtras) 

my_cars <- mtcars %>%
  dplyr::mutate(row_n = dplyr::row_number(), .before = mpg) %>%
  dplyr::select(row_n, mpg:drat)

tab1 <- my_cars %>%
  dplyr::slice(1:16) %>%
  gt() %>%
  gtExtras::gt_color_rows(columns = row_n, domain = 1:32)

tab2 <- my_cars %>%
  dplyr::slice(17:32) %>%
  gt() %>%
  gtExtras::gt_color_rows(columns = row_n, domain = 1:32)

listed_tables <- list(tab1, tab2)

gt_two_column_layout(listed_tables)

image

jthomasmock commented 5 months ago

Howdy thanks for the feedback! Two column layout is intended to be used in either a Quarto doc or with raw htmltools for display. I know some folks do use it for screenshots as well. I believe gt upstream is working on some combined multi-column layouts that have merged titles, but it's not something I'm looking to take on at this time given my past attempts.