Add `repeat_header` LaTeX option for #13
add the tests folder to build ignore to reduce the size
diff --git a/.Rbuildignore b/.Rbuildignore
index 4952b99..8128b14 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -1,3 +1,4 @@
 ^.*\.Rproj$
 ^\.Rproj\.user$
 ^docs$
+^tests$
diff --git a/R/kable_styling.R b/R/kable_styling.R
index 7e6f92a..74f11e1 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -12,14 +12,16 @@
 #' `bordered`, `hover`, `condensed` and `responsive`.
 #' @param latex_options A character vector for LaTeX table options. Please see
 #' package vignette for more information. Possible options include
-#' `basic`, `striped`, `hold_position`, `scale_down`. `striped` will add
-#' alternative row colors to the table. It will imports `LaTeX` package `xcolor`
-#' if enabled. `hold_position` will "hold" the floating table to the exact
-#' position. It is useful when the `LaTeX` table is contained in a `table`
-#' environment after you specified captions in `kable()`. It will force the
-#' table to stay in the position where it was created in the document.
+#' `basic`, `striped`, `hold_position`, `scale_down` & `repeat_header`.
+#' `striped` will add alternative row colors to the table. It will imports
+#' `LaTeX` package `xcolor` if enabled. `hold_position` will "hold" the floating
+#' table to the exact position. It is useful when the `LaTeX` table is contained
+#'  in a `table` environment after you specified captions in `kable()`. It will
+#'  force the table to stay in the position where it was created in the document.
 #' `scale_down` is useful for super wide table. It will automatically adjust
-#' the table to page width.
+#' the table to page width. `repeat_header` in only meaningful in a longtable
+#' environment. It will let the header row repeat on every page in that long
+#' table.
 #' @param full_width A `TRUE` or `FALSE` variable controlling whether the HTML
 #' table should have 100\% width. Since HTML and pdf have different flavors on
 #' the preferable format for `full_width`. If not specified, a HTML table will
@@ -168,7 +170,7 @@
 
   latex_options <- match.arg(
     latex_options,
-    c("basic", "striped", "hold_position", "scale_down"),
+    c("basic", "striped", "hold_position", "scale_down", "repeat_header"),
     several.ok = T
   )
 
@@ -189,6 +191,10 @@
     out <- styling_latex_scale_down(out, table_info)
   }
 
+  if ("repeat_header" %in% latex_options & table_info$tabular == "longtable") {
+    out <- styling_latex_repeat_header(out, table_info)
+  }
+
   if (full_width) {
     out <- styling_latex_full_width(out, table_info)
   }
@@ -230,6 +236,12 @@
   sub(table_info$end_tabular, paste0(table_info$end_tabular, "\\}"), x)
 }
 
+styling_latex_repeat_header <- function(x, table_info) {
+  row_one <- table_info$contents[2]
+  new_row_one <- paste0("\\\\endhead\n", row_one)
+  return(sub(row_one, new_row_one, x))
+}
+
 styling_latex_full_width <- function(x, table_info) {
   size_matrix <- sapply(sapply(table_info$contents, str_split, " & "), nchar)
   col_max_length <- apply(size_matrix, 1, max) + 4
diff --git a/inst/NEWS b/inst/NEWS
index 0c02f28..a4ea393 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -9,6 +9,9 @@
 
 * Fixed a bug in grouped rows with ()[].
 
+* Add a new LaTeX option `repeat_header` in `kable_styling` for repeating
+header rows in a longtable environment.
+
 kableExtra 0.2.1
 --------------------------------------------------------------------------------
 
diff --git a/man/kable_styling.Rd b/man/kable_styling.Rd
index 09893d6..90aca6f 100644
--- a/man/kable_styling.Rd
+++ b/man/kable_styling.Rd
@@ -19,14 +19,16 @@
 
 \item{latex_options}{A character vector for LaTeX table options. Please see
 package vignette for more information. Possible options include
-`basic`, `striped`, `hold_position`, `scale_down`. `striped` will add
-alternative row colors to the table. It will imports `LaTeX` package `xcolor`
-if enabled. `hold_position` will "hold" the floating table to the exact
-position. It is useful when the `LaTeX` table is contained in a `table`
-environment after you specified captions in `kable()`. It will force the
-table to stay in the position where it was created in the document.
+`basic`, `striped`, `hold_position`, `scale_down` & `repeat_header`.
+`striped` will add alternative row colors to the table. It will imports
+`LaTeX` package `xcolor` if enabled. `hold_position` will "hold" the floating
+table to the exact position. It is useful when the `LaTeX` table is contained
+ in a `table` environment after you specified captions in `kable()`. It will
+ force the table to stay in the position where it was created in the document.
 `scale_down` is useful for super wide table. It will automatically adjust
-the table to page width.}
+the table to page width. `repeat_header` in only meaningful in a longtable
+environment. It will let the header row repeat on every page in that long
+table.}
 
 \item{full_width}{A `TRUE` or `FALSE` variable controlling whether the HTML
 table should have 100\% width. Since HTML and pdf have different flavors on
diff --git a/tests/visual_tests/longtable.Rmd b/tests/visual_tests/longtable.Rmd
new file mode 100644
index 0000000..7070302
--- /dev/null
+++ b/tests/visual_tests/longtable.Rmd
@@ -0,0 +1,20 @@
+---
+title: "Untitled"
+output: pdf_document
+---
+
+```{r setup, include=FALSE}
+knitr::opts_chunk$set(echo = TRUE)
+```
+
+```{r}
+library(tidyverse)
+library(knitr)
+library(kableExtra)
+
+dt <- rbind(mtcars, mtcars) 
+
+kable(dt, "latex", longtable = T, booktabs = T) %>%
+  add_header_above(c(" ", "a" = 6, "b" = 5)) %>%
+  kable_styling(latex_options = "repeat_header")
+```