rmarkdownxtablekableioslides

Reducing column header names font size in kable tables in Rmarkdown (ioslides)


In all my tables that I'm trying to produces in ioslides I am getting a result that shows a massive column name. How do I shrink this to make the table look okay?

Here is one example, but the same thing happens with every table. What am I missing? Ideally I'd want the content in the table to be the same font size.

Markdown:

## Test
``````{r, Test,echo=FALSE}
options("kableExtra.html.bsTable" = T)
kable(df, format= "html") %>%
  kable_styling(full_width = F, bootstrap_options = c("striped", "hover", "condensed"), font_size = 12.5)

Image of my output: Image of my table


Solution

  • You can change row sizes by using row_spec()

    Since the header is interpreted as the row 0 you can change your header independently to fit your needings.

    Try

    kable(df, format= "html") %>%
      kable_styling(full_width = F, bootstrap_options = c("striped", "hover", "condensed"), font_size = 12.5) %>%
      row_spec(0, font_size=9)
    

    for more settings check row_spec