经过一些R计算,我得到了一个看起来像这样的矩阵:
matrix <- cbind(c(00,01,02),c("some text","random stuff","special characters'"), c("0.12%","\\cellcolor{red!25}3.67%","1.61%"))
我正尝试将其导出为乳胶,如下所示:
file.name <- "file.name"
file.caption <- "file.caption"
print(xtable(matrix, align = c("l","r","r","r"),
label = paste("tab:", file.name, sep = "", collapse = NULL),
caption = file.caption),
type = "latex",
size="\\normalsize",
caption.placement = "top",
# file = paste("graphs/", file.name, ".tex", sep = "", collapse = NULL),
floating = FALSE,
tabular.environment = "longtable",
sanitize.text.function = function(x) x)
如果我不sanitize
,则pdf会显示“ \ cellcolor {red!25}”(显然,我希望对单元格进行着色)。如果我sanitize
,因为有“%”,所以我不能排版file.tex。
我尝试了sanitize.text.function = function(x) x
和sanitize.text.function = identity
...没有成功。
任何想法?