Fixed a bug when row_spec and cell_spec used together
diff --git a/R/column_spec.R b/R/column_spec.R
index 0f36f65..bd9a425 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -516,8 +516,9 @@
     new_row[column] <- paste0("\\\\sout\\{", new_row[column], "\\}")
   }
   if (!is.null(color)) {
+    clean_columns <- unlist(lapply(new_row[column], clear_color_latex))
     new_row[column] <- paste0("\\\\textcolor", latex_color(color), "\\{",
-                              new_row[column], "\\}")
+                              clean_columns, "\\}")
   }
   # if (!is.null(font_size)) {
   #   new_row[column] <- paste0("\\\\begingroup\\\\fontsize\\{", font_size, "\\}\\{",
@@ -529,8 +530,9 @@
   #                             new_row[column], "\\}")
   # }
   if (!is.null(background)) {
+    clean_columns <- unlist(lapply(new_row[column], clear_color_latex, TRUE))
     new_row[column] <- paste0("\\\\cellcolor", latex_color(background), "\\{",
-                              new_row[column], "\\}")
+                              clean_columns, "\\}")
   }
 
   if (!is.null(link)) {
diff --git a/R/row_spec.R b/R/row_spec.R
index cc8978e..92d8150 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -249,9 +249,16 @@
   }
   if (!is.null(color)) {
     new_row <- lapply(new_row, function(x) {
+      x <- clear_color_latex(x)
       paste0("\\\\textcolor", latex_color(color), "\\{", x, "\\}")
     })
   }
+  if (!is.null(background)) {
+    new_row <- lapply(new_row, function(x) {
+      x <- clear_color_latex(x, background = TRUE)
+      paste0("\\\\cellcolor", latex_color(background), "\\{", x, "\\}")
+    })
+  }
   if (!is.null(font_size)) {
     new_row <- lapply(new_row, function(x) {
       paste0("\\\\begingroup\\\\fontsize\\{", font_size, "\\}\\{",
@@ -284,9 +291,9 @@
 
   new_row <- paste(unlist(new_row), collapse = " & ")
 
-  if (!is.null(background)) {
-    new_row <- paste0("\\\\rowcolor", latex_color(background), "  ", new_row)
-  }
+  # if (!is.null(background)) {
+  #   new_row <- paste0("\\\\rowcolor", latex_color(background), "  ", new_row)
+  # }
 
   if (!hline_after & is.null(extra_latex_after)) {
     return(new_row)
@@ -303,3 +310,5 @@
     return(c(new_row, latex_after))
   }
 }
+
+
diff --git a/R/util.R b/R/util.R
index 528e9bd..e623709 100644
--- a/R/util.R
+++ b/R/util.R
@@ -152,3 +152,17 @@
   x <- linebreak(x, align = latex_align, double_escape = TRUE)
 }
 
+clear_color_latex <- function(x, background = F) {
+  term <- if (background) "cellcolor" else "textcolor"
+  regex_1 <- sprintf(
+    "\\\\\\\\%s\\\\\\[HTML\\\\\\]\\\\\\{[a-zA-Z0-9]*\\\\\\}\\\\\\{", term
+  )
+  regex_2 <- sprintf(
+    "\\\\\\\\%s\\\\\\{[a-zA-Z0-9]*\\\\\\}\\\\\\{", term
+  )
+  origin_len <- nchar(x)
+  x <- stringr::str_remove(x, regex_1)
+  x <- stringr::str_remove(x, regex_2)
+  return(ifelse(nchar(x) != origin_len, stringr::str_remove(x, "\\\\\\}$"), x))
+}
+
diff --git a/R/zzz.R b/R/zzz.R
index 3fd88fb..36133e7 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -18,8 +18,8 @@
       # usepackage_latex("xcolor")
     }
   }
-  # auto_format <- getOption("kableExtra.auto_format", default = TRUE)
-  # if (auto_format) auto_set_format()
+  auto_format <- getOption("kableExtra.auto_format", default = TRUE)
+  if (auto_format) auto_set_format()
   if (!is.null(rmarkdown::metadata$output) &&
       rmarkdown::metadata$output %in% c(
         "ioslides_presentation", "slidy_presentation",