79164101

Date: 2024-11-06 20:08:17
Score: 0.5
Natty:
Report link

The developers of kableExtra were able to resolve this issue. Details found here. add_header_above must be placed prior to kable_styling

---
title: "Test"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(knitr)
library(kableExtra)
```

Some text to anchor the first table.

```{r test-table}
tibble(col1 = rep("Random text", 80),
       n1 = 1:80,
       perc1 = 1:80,
       n2 = 1:80,
       perc2 = 1:80) %>% 
  kbl(col.names = c("Category", "n", "\\%", "n", "\\%"),
      caption = "Reproducible caption",
      longtable = TRUE, escape = FALSE, booktabs = TRUE, linesep = "") %>% 
  add_header_above(c(" " = 1,
                     "Group 1" = 2,
                     "Group 2" = 2)) %>%
  kable_styling(latex_options = c("HOLD_position", "repeat_header"),
                position = "left")
```
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Jeff Hoover