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
)
an stable object; this can be the result of calling stable()
or
stable_long()
.
used to build intermediate and output file names.
directory for building the pdf file.
the font to use; alternative values include roboto
and
utopia
; passed to st_to_standalone()
.
the page width (in inches) when building with pdflatex
;
passed to st_to_standalone()
; see details.
passed as an option to standalone
latex output type; see
details.
number of times to build the pdf file
A string containing the path to the rendered 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).
# 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/Rtmp0B7ZA7/temp_libpath16ba41e11948/pmtables/tex/standalone-preview.tex