#' Convert a LaTeX table to an image and place it in a rmarkdown document
#'
#' @description This is a LaTeX-only function. This function will render the
#' raw LaTeX code (could be codes generated by other table packages like
#' `xtable`) to generate a table, convert it to an image and put it back to a
#' rmarkdown environment. It is a "better than nothing" solution to print high
#' quality tables in rmarkdown Word document. By using this, you need to take
#' the responsibility of explaining to your collaborators why they can't make
#' edits to the tables in Word. 😂
#'
#' Also, if a filename is provided, user has the option to "save" the table to
#' an image file like `ggplot2::ggsave()`.
#'
#' The idea of this function was coming from [this StackOverflow question](https://stackoverflow.com/questions/44711313/save-rmarkdowns-report-tables-and-figures-to-file).
#' The approach was learned and adopted from the [texpreview](https://github.com/metrumresearchgroup/texPreview)
#' package, which allows you to preview the results of TeX code in the Viewer panel.
#'
#' @param kable_input Raw LaTeX code to generate a table. It doesn't have to
#' came from `kable` or `kableExtra`.
#' @param filename Character String. If specified, the image will be saved under
#' the specified (path &) name. You don't need to put file format like ".png"
#' here.
#' @param file_format Character String to specify image format, such as `png`,
#' `jpeg`, `gif`, `tiff`, etc. Default is `png`.
#' @param latex_header_includes A character vector of extra LaTeX header stuff.
#' Each element is a row. You can have things like
#' `c("\\usepackage{threeparttable}", "\\usepackage{icons}")`
#' @param keep_pdf A T/F option to control if the mid-way standalone pdf should
#' be kept. Default is `FALSE`.
#'
#' @examples kable_as_image(knitr::kable(mtcars, "latex", booktabs = TRUE), "mtcars")
#'
#' @export
kable_as_image <- function(kable_input, filename = NULL,
                           file_format = "png",
                           latex_header_includes = NULL,
                           keep_pdf = FALSE) {
  temp_tex <- c(
    "\\documentclass[border=1mm, preview]{standalone}",
    "\\usepackage[active,tightpage]{preview}",
    "\\usepackage{varwidth}",
    "\\usepackage{amssymb,amsmath}",
    "\\usepackage{ifxetex,ifluatex}",
    "\\usepackage{fixltx2e}",
    "\\usepackage{polyglossia}",
    "\\setmainlanguage{$mainlang$}",
    "\\usepackage{booktabs}",
    "\\usepackage{longtable}",
    "\\usepackage{array}",
    "\\usepackage{multirow}",
    "\\usepackage[table]{xcolor}",
    "\\usepackage{wrapfig}",
    "\\usepackage{colortbl}",
    "\\usepackage{graphicx}",
    "\\usepackage{mathspec}",
    "\\usepackage{xltxtra,xunicode}",
    latex_header_includes,
    "\\begin{document}",
    enc2utf8(as.character(kable_input)),
    "\\end{document}"
  )
  temp_tex <- paste(temp_tex, collapse = "\n")
  temp_file <- paste0("table_", format(Sys.time(), "%Y-%m-%d_%H:%M:%S"))
  write_file(temp_tex, paste0(temp_file, ".tex"))
  system(paste0("xelatex -interaction=batchmode ", temp_file, ".tex"))
  temp_file_delete <- paste0(temp_file, c(".tex", ".aux", ".log"))
  unlink(temp_file_delete)

  table_img_pdf <- image_read(paste0(temp_file, ".pdf"), density = 300)
  if (!keep_pdf) {
    unlink(paste0(temp_file, ".pdf"))
  }
  table_img <- image_convert(table_img_pdf, file_format)
  if (!is.null(filename)) {
    temp_img <- paste0(filename, ".", file_format)
  } else {
    temp_img <- tempfile(fileext = paste0(".", file_format))
  }
  image_write(table_img, temp_img)

  include_graphics(temp_img)
}
