Search code examples
rknitrr-markdownbeamer

How to change font size in knitr::kable in Beamer slides?


In Beamer presentation created using rmarkdown I have a slide with table, e.g.

## Slide with table

```{r, asis = TRUE}
dat <- mtcars
knitr::kable(dat)
```

How can I control the font size so that the whole table fits the slide?


Solution

  • I'd suggest trying the kableExtra package.

    Otherwise, the easiest way I know of is to specify a CSS class for the table and then define the font size in CSS. See how to colour different Rmarkdown kable tables in different colour