rr-markdownbookdownkablekableextra

Increase line/row spacing with kableExtra


Is there a way to increase the line spacing with kableExtra for a pdf output in r-markdown or bookdown?

library(knitr)
library(kableExtra)
kable(
  head(iris, 5), caption = 'Iris Table',
  booktabs = TRUE) %>%
  kable_styling(latex_options = "striped")

enter image description here


Solution

  • You can just do it using the LaTeX command \arraystretch:

    ---
    output: pdf_document
    ---
    
    ```{r setup, include=FALSE}
    library(kableExtra)
    library(tidyverse)
    ```
    
    
    \renewcommand{\arraystretch}{2}
    ```{r, echo=FALSE}
    library(knitr)
    library(kableExtra)
    kable(head(iris, 5), caption = 'Iris Table',booktabs = TRUE) %>%
      kable_styling(latex_options = "striped")
    ```
    

    Notice that all following tables would use the same spacing. But you could reset it using \renewcommand{\arraystretch}{1}

    enter image description here