Sure thing. I looked at the .Rmd file again and noticed the problem is stemming from one section, which I believe is this chunk (the one represented by the reprex I put earlier). The table is here as a jpg (if it helps I can make it as a normal df but I'm assuming there's something involved with just how this chunk is written).
title: "Test"
output: pdf_document
``` {r Table 2, eval = TRUE, echo=FALSE, warning=FALSE}
library(knitr)
library(kableExtra)
table2 <- read.csv(table, stringsAsFactors = FALSE, check.names = FALSE)
kable(table2, booktabs = TRUE, caption = "**Table 2. Summary of variables**", format = 'latex', escape = FALSE) %>%
kable_styling(latex_options = c("scale_down", "hold_position"), font_size = 12, protect_latex = TRUE) %>%
add_header_above(c(" "," "," "," "," "," ", "observed values" = 3, " ")) %>%
column_spec(4, width = "7cm") %>%
pack_rows("Dependent variable", 1, 1, latex_gap_space = "1em", colnum = 1, hline_before = FALSE) %>%
pack_rows("Independent variables", 2, 18, latex_gap_space = ".4em", colnum = 1, hline_before = FALSE) %>%
pack_rows("tree size", 5, 6, latex_gap_space = ".4em", colnum = 1, hline_before = FALSE, bold = FALSE, italic = TRUE) %>%
pack_rows("microhabitat", 7, 11, latex_gap_space = ".4em", colnum = 1, hline_before = FALSE, bold = FALSE, italic = TRUE) %>%
pack_rows("species' traits", 12, 18, latex_gap_space = ".4em", colnum = 1, hline_before = FALSE, bold = FALSE, italic = TRUE) %>%
kable_styling()