Fix #476
diff --git a/R/group_rows.R b/R/group_rows.R
index c7d5178..835b036 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -208,9 +208,17 @@
                       regex_escape(extra_latex_after, double_backslash = TRUE))
   }
   new_rowtext <- paste0(pre_rowtext, rowtext)
-  out <- sub(paste0(rowtext, "\\\\\\\\\n"),
-  	         paste0(new_rowtext, "\\\\\\\\\n"),
-  	         out)
+  if (start_row + 1 == table_info$nrow &
+      !is.null(table_info$repeat_header_latex)) {
+    out <- sub(paste0(rowtext, "\\\\\\\\\\*\n"),
+               paste0(new_rowtext, "\\\\\\\\\\*\n"),
+               out)
+  } else {
+    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
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 67e0234..7e4c5e7 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -317,6 +317,7 @@
   if ("repeat_header" %in% latex_options & table_info$tabular == "longtable") {
     out <- styling_latex_repeat_header(out, table_info, repeat_header_text,
                                        repeat_header_method, repeat_header_continued)
+    table_info$repeat_header_latex <- TRUE
   }
 
   if (full_width) {