0

我想在功能中使用LaTeX命令add_header_abovekableExtra

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)
4

1 回答 1

2

您可以使用escape = FALSE

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

在此处输入图像描述

于 2019-02-06T13:29:50.837 回答