remove \lab{} in second header in repeat_header for longtable LaTeX
diff --git a/R/kable_styling.R b/R/kable_styling.R
index a824d77..d7aa1f5 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -266,7 +266,8 @@
)
} else {
if (repeat_header_method == "append") {
- repeat_header_text <- paste(table_info$caption, repeat_header_text)
+ caption_without_lab <- sub("\\\\label\\{.*?\\}", "", table_info$caption)
+ repeat_header_text <- paste(caption_without_lab, repeat_header_text)
}
continue_line <- paste0("\\caption{", repeat_header_text, "}\\\\")
}
diff --git a/inst/NEWS b/inst/NEWS
index 70009f1..8ee3575 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -10,11 +10,11 @@
* Lowered R version requirement to R 3.1.0
-* Added testthat
+* Added testthat (#28, thank you @wibe)
* For all HTML table functions, changed reading method from `xml2::read_xml` to
`xml2::read_html` plus some extra steps to avoid errors when HTML contents
-don't fulfill XHTML requirements
+don't fulfill XHTML requirements (#24)
* For all HTML table functions, improved exportation method to remove the XML
declaration. (Stackoverflow: https://stackoverflow.com/questions/45262308/knit2wp-adds-text-with-kableextra)
diff --git a/tests/visual_tests/longtable.Rmd b/tests/visual_tests/longtable.Rmd
index b586d79..fef0f3b 100644
--- a/tests/visual_tests/longtable.Rmd
+++ b/tests/visual_tests/longtable.Rmd
@@ -22,11 +22,16 @@
```
```{r}
-kable(dt, "latex", longtable = T, caption = "test", booktabs = T) %>%
+kable_input <- kable(dt, "latex", longtable = T, caption = "test", booktabs = T) %>%
kable_styling(latex_options = c("striped", "repeat_header"), repeat_header_text = "(...)")
```
```{r}
+kable(dt, "latex", longtable = T, caption = "test", booktabs = T) %>%
+ kable_styling(latex_options = c("striped", "repeat_header"), repeat_header_text = "continue of table 2", repeat_header_method = "replace")
+```
+
+```{r}
kable(dt, "latex", longtable = T, booktabs = T) %>%
add_header_above(c(" ", "a" = 6, "b" = 5)) %>%
kable_styling(latex_options = "repeat_header", repeat_header_text = "(cont.)")