Merge pull request #255 from quocpeyrot/issue254

Fix #254
diff --git a/R/add_indent.R b/R/add_indent.R
index a8a455e..35cc196 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -48,7 +48,9 @@
 
   for (i in positions + table_info$position_offset) {
     rowtext <- table_info$contents[i]
-    out <- sub(rowtext, latex_indent_unit(rowtext), out, perl = TRUE)
+    out <- sub(paste0(rowtext, "\\\\\\\\\n"),
+               paste0(latex_indent_unit(rowtext), "\\\\\\\\\n"),
+               out, perl = TRUE)
     table_info$contents[i] <- latex_indent_unit(rowtext)
   }
   out <- structure(out, format = "latex", class = "knitr_kable")
diff --git a/R/group_rows.R b/R/group_rows.R
index f6f0d43..4ac5654 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -186,7 +186,9 @@
                       regex_escape(extra_latex_after, double_backslash = TRUE))
   }
   new_rowtext <- paste0(pre_rowtext, rowtext)
-  out <- sub(rowtext, new_rowtext, out)
+  out <- sub(paste0(rowtext, "\\\\\\\\\n"),
+  	         paste0(new_rowtext, "\\\\\\\\\n"),
+  	         out)
   out <- gsub("\\\\addlinespace\n", "", out)
   out <- structure(out, format = "latex", class = "knitr_kable")
   table_info$group_rows_used <- TRUE