added linebreak support to all kableExtra functions
diff --git a/R/add_footnote.R b/R/add_footnote.R
index eaee90c..feb1269 100644
--- a/R/add_footnote.R
+++ b/R/add_footnote.R
@@ -97,6 +97,7 @@
# Clean the entry for labels
if (escape) {
label <- escape_latex(label)
+ label <- linebreak(label)
}
label <- gsub("\\\\", "\\\\\\\\", label)
diff --git a/R/footnote.R b/R/footnote.R
index 77452ab..42b76a5 100644
--- a/R/footnote.R
+++ b/R/footnote.R
@@ -84,7 +84,9 @@
footnote_titles <- lapply(footnote_titles, escape_html)
} else {
footnote_contents <- lapply(footnote_contents, escape_latex2)
+ footnote_contents <- lapply(footnote_contents, linebreak)
footnote_titles <- lapply(footnote_titles, escape_latex2)
+ footnote_titles <- lapply(footnote_titles, linebreak)
}
}
footnote_table <- footnote_table_maker(
diff --git a/R/group_rows.R b/R/group_rows.R
index c7531b1..f93a4d7 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -154,8 +154,8 @@
}
if (escape) {
- group_label <- escape_latex(group_label)
- group_label <- gsub("\\\\", "\\\\\\\\", group_label)
+ group_label <- escape_latex2(group_label)
+ group_label <- linebreak(group_label, align = latex_align, double_escape = TRUE)
}
if(bold){
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 0ef0e0b..af5691d 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ
diff --git a/docs/best_practice_for_newline_in_latex_table.Rmd b/docs/best_practice_for_newline_in_latex_table.Rmd
index 52c3ea8..f798484 100644
--- a/docs/best_practice_for_newline_in_latex_table.Rmd
+++ b/docs/best_practice_for_newline_in_latex_table.Rmd
@@ -47,7 +47,7 @@
col.names = linebreak(c("Item\n(Name)", "Value\n(Number)"), align = "c"))
```
-### Linebreak in kableExtra functions
+### Linebreak in other kableExtra functions
If you have a need to put a linebreak in `kableExtra` functions such as `add_header_above` and `group_rows`, just go ahead and use `\n` and it will be automatically converted. Note that this feature is controlled by the `escape` option in those functions.
```{r}
@@ -55,7 +55,7 @@
mutate_all(linebreak) %>%
kable("latex", booktabs = T, escape = F,
col.names = linebreak(c("Item\n(Name)", "Value\n(Number)"), align = "c")) %>%
- add_header_above(c("Combined\nTitle" = 2))
-
+ add_header_above(c("Combined\nTitle" = 2)) %>%
+ group_rows("Group\n1", 2, 2)
```
diff --git a/docs/best_practice_for_newline_in_latex_table.pdf b/docs/best_practice_for_newline_in_latex_table.pdf
index 518fa66..15528fc 100644
--- a/docs/best_practice_for_newline_in_latex_table.pdf
+++ b/docs/best_practice_for_newline_in_latex_table.pdf
Binary files differ