put back caption for multi-page longtable in latex
diff --git a/R/kableExtra-package.R b/R/kableExtra-package.R
index 72978fb..a753a32 100644
--- a/R/kableExtra-package.R
+++ b/R/kableExtra-package.R
@@ -1,7 +1,7 @@
 #' kableExtra
 #'
 #' @importFrom stringr str_count str_split str_match str_detect str_match_all
-#' str_extract str_replace_all str_trim str_extract_all
+#' str_extract str_replace_all str_trim str_extract_all str_sub
 #' @importFrom xml2 read_xml xml_attr xml_has_attr xml_attr<- read_html
 #' xml_child xml_children xml_name xml_add_sibling xml_add_child xml_text
 #' xml_text<-
diff --git a/R/kable_styling.R b/R/kable_styling.R
index e68f01a..1dce2be 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -169,7 +169,7 @@
                              position = c("center", "left", "right",
                                           "float_left", "float_right"),
                              font_size = NULL,
-                             repeat_header_text = "\\ldots continued") {
+                             repeat_header_text = "(continued)") {
 
   latex_options <- match.arg(
     latex_options,
@@ -248,10 +248,19 @@
     header_rows_start <- which(x == "\\hline")[1]
     header_rows_end <- which(x == "\\hline")[2]
   }
-  continue_line <- paste0(
-    "\\multicolumn{", table_info$ncol, "}{@{}l}{", repeat_header_text,
-    "}\\\\"
-  )
+
+  if (is.na(table_info$caption)) {
+    continue_line <- paste0(
+      "\\multicolumn{", table_info$ncol, "}{@{}l}{", repeat_header_text,
+      "}\\\\"
+    )
+  } else {
+    continue_line <- paste0(
+      "\\caption{", table_info$caption, " ", repeat_header_text,
+      "}\\\\"
+    )
+  }
+
   x <- c(
     x[1:header_rows_end],
     "\\endfirsthead",
diff --git a/R/magic_mirror.R b/R/magic_mirror.R
index e00032c..7b35e74 100644
--- a/R/magic_mirror.R
+++ b/R/magic_mirror.R
@@ -58,6 +58,7 @@
   kable_info$ncol <- nchar(kable_info$align)
   # Caption
   kable_info$caption <- str_match(kable_input, "caption\\{(.*?)\\n")[2]
+  kable_info$caption <- str_sub(kable_info$caption, 1, -4)
   # N of rows
   kable_info$nrow <- str_count(kable_input, "\\\\\n") -
     # in the dev version (currently as of 11.2015) of knitr, when longtable is