add text/bg color to latex except column bg color
diff --git a/R/row_spec.R b/R/row_spec.R
index 6615365..060c27f 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -82,7 +82,8 @@
return(out)
}
-row_spec_latex <- function(kable_input, row, bold, italic, monospace) {
+row_spec_latex <- function(kable_input, row, bold, italic, monospace,
+ color, background) {
table_info <- magic_mirror(kable_input)
target_row <- table_info$contents[row + 1]
new_row <- latex_row_cells(target_row)
@@ -101,8 +102,18 @@
paste0("\\\\ttfamily{", x, "}")
})
}
+
+ if (!is.null(color)) {
+ new_row <- lapply(new_row, function(x) {
+ paste0("\\\\textcolor{", color, "}{", x, "}")
+ })
+ }
new_row <- paste(unlist(new_row), collapse = " & ")
+ if (!is.null(background)) {
+ new_row <- paste0("\\\\rowcolor{", background, "} ", new_row)
+ }
+
out <- sub(target_row, new_row, as.character(kable_input), perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
attr(out, "kable_meta") <- table_info