Improve footnote
diff --git a/R/footnote.R b/R/footnote.R
index 0d1b3be..54929d0 100644
--- a/R/footnote.R
+++ b/R/footnote.R
@@ -197,24 +197,31 @@
table_info <- magic_mirror(kable_input)
out <- enc2utf8(as.character(kable_input))
- if (table_info$tabular == "longtable" & threeparttable == TRUE) {
- threeparttable <- FALSE
- warning("threeparttable does not support longtable.")
- }
+ # if (table_info$tabular == "longtable" & threeparttable == TRUE) {
+ # threeparttable <- FALSE
+ # warning("threeparttable does not support longtable.")
+ # }
footnote_text <- latex_tfoot_maker(footnote_table, footnote_as_chunk,
table_info$ncol, threeparttable)
if (threeparttable) {
out <- sub(paste0("\\\\begin\\{", table_info$tabular, "\\}"),
- paste0("\\\\begin{ThreePartTable}\n\\\\begin{",
+ paste0("\\\\begin{ThreePartTable}\n\\\\begin{TableNotes}",
+ ifelse(footnote_as_chunk, "[para]", ""),
+ "\n\\\\small\n", footnote_text,
+ "\n\\\\end{TableNotes}\n\\\\begin{",
table_info$tabular, "}"),
out)
out <- sub(table_info$end_tabular,
paste0("\\\\end{", table_info$tabular,
- "}\n\\\\begin{tablenotes}",
- ifelse(footnote_as_chunk, "[para]", ""),
- "\n\\\\small\n", footnote_text,
- "\n\\\\end{tablenotes}\n\\\\end{ThreePartTable}"),
+ "}\n\\\\end{ThreePartTable}"),
out)
+ if (table_info$booktabs) {
+ out <- sub("\\\\bottomrule", "\\\\bottomrule\n\\\\insertTableNotes", out)
+ } else {
+ out <- sub("\\\\hline\n\\\\end\\{longtable\\}",
+ "\\\\hline\n\\\\insertTableNotes\n\\\\end\\{longtable\\}",
+ out)
+ }
} else if (table_info$booktabs) {
out <- sub("\\\\bottomrule",
paste0("\\\\bottomrule\n", footnote_text), out)
diff --git a/inst/NEWS.md b/inst/NEWS.md
index ceb1a23..1012f3d 100644
--- a/inst/NEWS.md
+++ b/inst/NEWS.md
@@ -2,8 +2,8 @@
--------------------------------------------------------------------------------
* Fixed #115, a bug in latex footnote about escaping.
* Fixed #116, a bug about the position of footnote in longtable with booktabs
-* replace threeparttable with threeparttablex
* Fixed #119, a bug between collapse_rows and add_header_above
+* Improve footnotes in longtable and replace threeparttable with threeparttablex. Now footnotes works smoothly in longtable, even with full width in tabu.
kableExtra 0.7.0