Fix #183
diff --git a/R/row_spec.R b/R/row_spec.R
index 638c611..d344c9a 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -198,12 +198,22 @@
                                      underline, strikeout,
                                      color, background, align, font_size, angle,
                                      hline_after, extra_latex_after)
-    if (length(new_row) == 1) {
-      out <- sub(target_row, new_row, out, perl = T)
+    if (i == 1 & table_info$tabular == "longtable") {
+      if (length(new_row) == 1) {
+        out <- gsub(target_row, new_row, out, perl = T)
+      } else {
+        out <- gsub(paste0(target_row, "\\\\\\\\"),
+                   paste(new_row, collapse = ""), out, perl = T)
+      }
     } else {
-      out <- sub(paste0(target_row, "\\\\\\\\"),
-                 paste(new_row, collapse = ""), out, perl = T)
+      if (length(new_row) == 1) {
+        out <- sub(target_row, new_row, out, perl = T)
+      } else {
+        out <- sub(paste0(target_row, "\\\\\\\\"),
+                   paste(new_row, collapse = ""), out, perl = T)
+      }
     }
+
     table_info$contents[i] <- new_row
   }