This is partially related to this post, but for some reason I seem not to be able to fix my issue. In Quarto, when I create a table using kable
with booktabs = TRUE
and linesep = ""
I get the expected results (no extra space every 5 rows):
---
title: "Test"
format: pdf
---
```{r}
library(kableExtra)
dat <- data.frame(v1 = letters[1:10], v2 = 1:10)
kable(dat, booktabs = TRUE, linesep = "")
```
If I use kable_styling()
to get a striped table, an extra space is added after the fifth row:
---
title: "Test"
format: pdf
---
```{r}
library(kableExtra)
dat <- data.frame(v1 = letters[1:10], v2 = 1:10)
kable(dat, booktable = TRUE, linesep = "") |>
kable_styling(latex_options = "striped")
```
I get the extra space when I use kable_styling()
even without booktabs = TRUE
:
---
title: "Test"
format: pdf
---
```{r}
library(kableExtra)
dat <- data.frame(v1 = letters[1:10], v2 = 1:10)
kable(dat) |>
kable_styling()
```
To my understanding this is not the expected behavior of kable_styling()
, is there something I am missing?
You are not missing something, the .tex
processing seems to work different here. However, you could include a \setlength{\defaultaddspace}{0pt}
in the header, this also makes the spaces go away.
---
title: "Test"
format:
pdf:
include-in-header:
text: |
\setlength{\defaultaddspace}{0pt}
---
```{r}
library(kableExtra)
dat <- data.frame(v1 = letters[1:10], v2 = 1:10)
kable(dat) |>
kable_styling()
```