kableExtra::landscape() LaTeX Error: Environment landscape undefined

Not exactly answering your question but if you can, I'd highly suggest uninstalling Miktex and installing tinytex instead.

If I use tinytex, your script knits just fine without any header configuration nonsense (note that I didn't need to specify the latex engine or anything).

---
title: "Cool Example Bro"
output: pdf_document
---

```{r}
library(kableExtra)

dt <- mtcars[1:5, 1:6]

knitr::kable(dt, "latex", caption = "Demo Table (Landscape)[note]", booktabs = T) %>%
  kable_styling (latex_options = c("hold_position")) %>%
  add_header_above( c(" ", "Group 1[note]" = 3, "Group 2[note]" = 3)) %>%
  add_footnote( c  ("This table is from mtcars",
                    "Group 1 contains mpg, cyl and disp",
                    "Group 2 contains hp, drat and wt"),
                notation = "symbol") %>%
  group_rows("Group 1", 4, 5) %>%
  landscape()

1 Like