Hao Zhu | 2a64dc6 | 2017-08-28 10:57:57 -0400 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/kable_as_image.R |
| 3 | \name{kable_as_image} |
| 4 | \alias{kable_as_image} |
| 5 | \title{Convert a LaTeX table to an image and place it in a rmarkdown document} |
| 6 | \usage{ |
| 7 | kable_as_image(kable_input, filename = NULL, file_format = "png", |
| 8 | latex_header_includes = NULL, keep_pdf = FALSE) |
| 9 | } |
| 10 | \arguments{ |
| 11 | \item{kable_input}{Raw LaTeX code to generate a table. It doesn't have to |
| 12 | came from \code{kable} or \code{kableExtra}.} |
| 13 | |
| 14 | \item{filename}{Character String. If specified, the image will be saved under |
| 15 | the specified (path &) name. You don't need to put file format like ".png" |
| 16 | here.} |
| 17 | |
| 18 | \item{file_format}{Character String to specify image format, such as \code{png}, |
| 19 | \code{jpeg}, \code{gif}, \code{tiff}, etc. Default is \code{png}.} |
| 20 | |
| 21 | \item{latex_header_includes}{A character vector of extra LaTeX header stuff. |
| 22 | Each element is a row. You can have things like |
| 23 | \code{c("\\usepackage{threeparttable}", "\\usepackage{icons}")}} |
| 24 | |
| 25 | \item{keep_pdf}{A T/F option to control if the mid-way standalone pdf should |
| 26 | be kept. Default is \code{FALSE}.} |
| 27 | } |
| 28 | \description{ |
| 29 | This is a LaTeX-only function. This function will render the |
| 30 | raw LaTeX code (could be codes generated by other table packages like |
| 31 | \code{xtable}) to generate a table, convert it to an image and put it back to a |
| 32 | rmarkdown environment. It is a "better than nothing" solution to print high |
| 33 | quality tables in rmarkdown Word document. By using this, you need to take |
Hao Zhu | 245931c | 2017-09-01 22:43:56 -0400 | [diff] [blame^] | 34 | the responsibility of explaining to your collaborators why they can't make |
| 35 | edits to the tables in Word. 😂 |
Hao Zhu | 2a64dc6 | 2017-08-28 10:57:57 -0400 | [diff] [blame] | 36 | |
| 37 | Also, if a filename is provided, user has the option to "save" the table to |
| 38 | an image file like \code{ggplot2::ggsave()}. |
| 39 | |
| 40 | The idea of this function was coming from \href{https://stackoverflow.com/questions/44711313/save-rmarkdowns-report-tables-and-figures-to-file}{this StackOverflow question}. |
| 41 | The approach was learned and adopted from the \href{https://github.com/metrumresearchgroup/texPreview}{texpreview} |
| 42 | package, which allows you to preview the results of TeX code in the Viewer panel. |
| 43 | } |
| 44 | \examples{ |
| 45 | kable_as_image(kable(mtcars, "latex"), "mtcars") |
| 46 | } |