blob: 1219ff89bf94175cf8403d5c0063383f30e99798 [file] [log] [blame]
Hao Zhuf1873a42019-01-07 15:57:01 -05001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/as_image.R
3\name{as_image}
4\alias{as_image}
5\title{Render the table as an format-independent image and use it in rmarkdown}
6\usage{
Hao Zhu62f50312019-01-15 15:19:29 -06007as_image(x, width = NULL, height = NULL, file = NULL, ...)
Hao Zhuf1873a42019-01-07 15:57:01 -05008}
9\arguments{
10\item{x}{kable input. Either HTML or LaTeX}
11
12\item{width}{Image width in inches. (1 inch = 2.54 cm)}
13
14\item{height}{Image height in inches. (1 inch = 2.54 cm)}
15
Hao Zhub361fb52019-01-15 12:24:10 -060016\item{file}{By default, as_image saves to an temp file, which works for
17normal rmarkdown. However if you are using things like xaringan, which can't
18be a standalone html, you can specify this file be the path you need, eg.
19"img/something.png"}
Hao Zhu62f50312019-01-15 15:19:29 -060020
21\item{...}{Additional arguments passed to save_kable.}
Hao Zhuf1873a42019-01-07 15:57:01 -050022}
23\description{
24This function generates a temporary png file using \code{save_kable}
25and then try to put it in an rmarkdown document using
26\code{knitr::include_graphics}.
27}
Hao Zhu9410a272020-08-03 01:11:47 -040028\examples{
29\dontrun{
30library(kableExtra)
31
32kable(mtcars, "latex", booktabs = T) \%>\%
33kable_styling(latex_options = c("striped", "scale_down")) \%>\%
34row_spec(1, color = "red") \%>\%
35as_image()
36}
37}