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().
Usage
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
)Arguments
- x
an stable object; this can be the result of calling
stable()orstable_long().- stem
used to build intermediate and output file names.
- dir
directory for building the pdf file.
- font
the font to use; alternative values include
robotoandutopia; passed tost_to_standalone().- textwidth
the page width (in inches) when building with
pdflatex; passed tost_to_standalone(); see details.- border
passed as an option to
standalonelatex output type; see details.- ntex
number of times to build the pdf file
Details
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).
Examples
# check that pdflatex is installed
if (FALSE) { # \dontrun{
Sys.which("pdflatex")
} # }
if (FALSE) { # \dontrun{
tab <- stable(stdata())
st_aspdf(tab)
} # }
# the template for building the image
temp <- system.file("tex", "standalone-preview.tex", package = "pmtables")
cat(temp, sep = "\n")
#> /tmp/RtmpiTT75j/temp_libpath3478c03955598e/pmtables/tex/standalone-preview.tex
