Improve latex package listing method
diff --git a/R/kable_as_image.R b/R/kable_as_image.R
index 5222daf..6a83118 100644
--- a/R/kable_as_image.R
+++ b/R/kable_as_image.R
@@ -46,13 +46,7 @@
     "\\usepackage{fixltx2e}",
     "\\usepackage{polyglossia}",
     "\\setmainlanguage{$mainlang$}",
-    "\\usepackage{booktabs}",
-    "\\usepackage{longtable}",
-    "\\usepackage{array}",
-    "\\usepackage{multirow}",
-    "\\usepackage[table]{xcolor}",
-    "\\usepackage{wrapfig}",
-    "\\usepackage{colortbl}",
+    latex_pkg_list(),
     "\\usepackage{graphicx}",
     "\\usepackage{mathspec}",
     "\\usepackage{xltxtra,xunicode}",
@@ -86,4 +80,5 @@
   image_write(table_img, temp_img)
 
   include_graphics(temp_img)
+  return(kable_input)
 }
diff --git a/R/util.R b/R/util.R
index 9587bd1..27f7d57 100644
--- a/R/util.R
+++ b/R/util.R
@@ -85,19 +85,7 @@
 #' @export
 kableExtra_latex_packages <- function() {
 
-  pkg_list <- c(
-    "  - \\usepackage{booktabs}",
-    "  - \\usepackage{longtable}",
-    "  - \\usepackage{array}",
-    "  - \\usepackage{multirow}",
-    "  - \\usepackage[table]{xcolor}",
-    "  - \\usepackage{wrapfig}",
-    "  - \\usepackage{float}",
-    "  - \\usepackage{colortbl}",
-    "  - \\usepackage{pdflscape}",
-    "  - \\usepackage{tabu}",
-    "  - \\usepackage{threeparttable}"
-  )
+  pkg_list <- paste0("  - ", latex_pkg_list())
 
   pkg_text <- paste0(
     "header-includes:\n",
@@ -106,3 +94,19 @@
 
   cat(pkg_text)
 }
+
+latex_pkg_list <- function() {
+  return(c(
+    "\\usepackage{booktabs}",
+    "\\usepackage{longtable}",
+    "\\usepackage{array}",
+    "\\usepackage{multirow}",
+    "\\usepackage[table]{xcolor}",
+    "\\usepackage{wrapfig}",
+    "\\usepackage{float}",
+    "\\usepackage{colortbl}",
+    "\\usepackage{pdflscape}",
+    "\\usepackage{tabu}",
+    "\\usepackage{threeparttable}"
+  ))
+}