kableExtra icon indicating copy to clipboard operation
kableExtra copied to clipboard

Striping with pack_rows

Open jamarav opened this issue 2 years ago • 0 comments

Hi everybody,

I would like to report a problem that I detected with manual striping. The main problem is that I'm not able to get striping for the following row after a pack_row index. I used the manual solution provided in #199.

library(kableExtra)
dt <- data.frame(
  title = c(rep("a", 3), rep("b", 3), rep("c", 3), rep("d", 3)),
  value = 1:12
)
kable(dt, "latex", booktabs = T) %>%
  row_spec(c(0:2, 6:8), extra_latex_after = "\\rowcolor{gray!10}") %>%
  collapse_rows(1, latex_hline = "none") %>%
  pack_rows(index = c('a' = 3, 'b' = 3, 'c' = 3, 'd' = 3))

When we don't use the pack_rows option we obtain the correct behavior. However, it is a bit confusing to use the extra_latex_after parameter. It provides the striping for the following row. For this reason, the first index is 0. I would like to know if it could be possible to provide a new extra parameter like extra_latex_before. Probably with this new option we are able to provide correct striping when we use the pack_rows option.

Thanks in advance

jamarav avatar Apr 08 '22 04:04 jamarav