Change table font size with distill

I'm currently checking out the great distill package and made good progress and applied the TIDYMODELS theme. I played around with the font sizes of the text, preferring smaller font sizes overall, so the relevant part of my CSS file currently looks as follows:

html {
  /*-- Main font sizes --*/
  --title-size:      50px;
  --body-size:       0.9rem;
  --code-size:       12px;
  --aside-size:      12px;
  --fig-cap-size:    12px;

However, the font sizes of the tables in my posts have not been adjusted and simply look too large in comparison. I tried to search for a solution to the issue, but unfortunately can't figure it out what to change. I tried adding --table-size: 6px;, I tried the solution provided SO and another solution on SO. Nothing changed.

Note that I have currently two different types of tables in my posts. One is created with this code chunk:

paged_table(DT)

The other one with

library(gtsummary)
# make dataset with a few variables to summarize
trial2 <- trial %>% select(age, grade, response, trt)

tbl_summary(
    data=DT[, list(Continent_Name, Market_cap, Net_debt, EBITDA, Revenue, EV_EBITDA)],
    by = Continent_Name, # split table by group
    missing = "no" # don't list missing data separately
  ) %>%
  add_n() %>% # add column with total number of non-missing observations
  add_p() %>% # test for a difference between groups
  modify_header(label = "**Variable**") %>% # update the column header
  bold_labels() 

Ideally, the solution works for all possible different ways of creating a table, e.g. with gtsummary, kable, paged_table, etc.

Here is a response to a somewhat similar question on stackoverflow.com using the gtsummary package. It seems that not every piece of a gt table is controllable with external CSS definitions. This user decided to convert their gtsummary tables to kableExtra where all their custom CSS was recognized.

For example,

library(gtsummary)

trial %>%
  tbl_summary() %>%
  as_kable_extra()

Hope it helps!

Thanks for the reply, much appreciated. Unfortunately, converting the tables to kable or kableExtra tables didn't solve the issue. For example, I converted one table now to kableExtra:

library(kableExtra)
DT %>%
  kbl(digits=2,
      format.args = list(big.mark = ',')) %>%
  kable_styling(bootstrap_options = c("striped", "hover"),
                fixed_thead = TRUE,
                font_size = 10) %>%
  scroll_box(width = "100%", height = "500px")

In the RStudio viewer, this produces a table with smaller font size and also the striped pattern:

I can only post one picture as a user, but it looks pretty much like the table on the kableExtra website

Pressing the knitr button in RStudio produces this rather unattractive table:

Any change I have made so far to the CSS style file had no impact on the look of the table. I also cannot find any information on how to change the look of a table. There is information on the distill website, but the examples there do not make any changes to the default design. Maybe it's simply not possible or I'm missing something obvious here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.