kableExtra::LaTeX 命令在 add_header_above 中无法正确呈现

kableExtra:: LaTeX commands are not rendering properly in add_header_above

我想在 kableExtra

add_header_above 函数中使用 LaTeX 命令
library(kableExtra)

x1 <- knitr::kable(head(mtcars), "html")
add_header_above(x1, c(" ", "Group 1" = 5, "Group 2" = 6))
add_header_above(x1, c(" ", "\alpha" = 5, "Group 2" = 6))

x2 <- knitr::kable(head(mtcars), "latex")
add_header_above(x2, c(" ", "Group 1" = 5, "Group 2" = 6))
add_header_above(x2, c(" ", "\alpha" = 5, "Group 2" = 6))

但是,LaTeX 命令 \alpha 没有正确呈现。有什么解决办法吗

已编辑

Test2 <- c(" ", مواطنين = "5", `غير مواطنين` = "6")
Test3 <- c(`\textarabic{}` = " ", `\textarabic{مواطنين}` = "5", 
`\textarabic{غير مواطنين}` = "6")

add_header_above(x1, Test2, escape = FALSE)

add_header_above(x1, Test3, escape = FALSE)

您可以使用 escape = FALSE:

add_header_above(x2, c(" ", "$\\alpha$" = 5, "Group 2" = 6), escape = FALSE)