View source: R/preview-standalone.R
st_aspdf | R Documentation |
Create a "standalone" pdf
snippet from an stable object using the
pdflatex
utility. The resultant pdf
file is saved on disk and the
relative path to the file is returned. st2pdf()
is an alias to
st_as_pdf()
.
st_aspdf(
x,
stem = "pmt-standalone-preview",
dir = tempdir(),
font = "helvetica",
textwidth = getOption("pmtables.textwidth", 6.5),
border = getOption("pmtables.image.border", "0.2cm 0.7cm"),
ntex = 1
)
st2pdf(
x,
stem = "pmt-standalone-preview",
dir = tempdir(),
font = "helvetica",
textwidth = getOption("pmtables.textwidth", 6.5),
border = getOption("pmtables.image.border", "0.2cm 0.7cm"),
ntex = 1
)
x |
an stable object; this can be the result of calling |
stem |
used to build intermediate and output file names. |
dir |
directory for building the pdf file. |
font |
the font to use; alternative values include |
textwidth |
the page width (in inches) when building with |
border |
passed as an option to |
ntex |
number of times to build the pdf file |
The pdf
file is built using pdflatex
so this utility must be installed.
The textwidth
argument is set to 6.5 inches by default to mimic a 8.5 x 11
page with 1 inch margins on the left and right. Setting textwidth
sets the
length of the \textwidth
latex macro to that value and also inserts an
invisible rule across the page with that width as well. This means for
skinny tables, there will be whitespace on the left and right, but the font
in the resultant images will be similar regardless of the width of the
table. To skip setting the latex \textwidth
macro, pass NULL
.
The border
argument can be one, two or four space-separated elements, each
formatted as "<number><unit>"
(e.g. "0.2cm"); pass one element to set the
same border on all sides; two elements to set the border on left/right
(first) and top/bottom (second); pass four elements to have separate borders
for the left, bottom, right and top (see the documentation for the
standalone
latex package).
A string containing the path to the rendered pdf
file.
st_aspng()
, st_as_image()
, st_image_show()
# check that pdflatex is installed
## Not run:
Sys.which("pdflatex")
## End(Not run)
## Not run:
tab <- stable(stdata())
st_aspdf(tab)
## End(Not run)
# the template for building the image
temp <- system.file("tex", "standalone-preview.tex", package = "pmtables")
cat(temp, sep = "\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.