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)