I'm trying to fill in the background color of a multirow cell with kableExtra, but like Goldilocks and the Three Bears, I can only get too little of the cell colored or too much (with color extending into the header). A reprex Rmd is below:
---
title: "Untitled"
output: pdf_document
---
```{r test, message = FALSE}
library("tidyverse")
library("kableExtra")
## Create data
dat <- tibble(
x = 1:5,
y = 6:10,
summary = "foo"
)
## This fills in only the bottom cell of the collapsed cells
dat %>%
mutate(summary = cell_spec(summary, "latex", background = "red")) %>%
kable("latex", escape = FALSE) %>%
add_header_above(c("new" = 2, " " = 1)) %>%
collapse_rows(columns = 3)
## This half-fills the header with the background color
dat %>%
kable("latex") %>%
column_spec(3, background = "red") %>%
add_header_above(c("new" = 2, " " = 1)) %>%
collapse_rows(columns = 3)
```
The above yields the following results:
Is there a way I can get just the foo
cell (fully) colored in?