Use st2article() to see tables in a plain pdf TeX document. Use st2report() to see tables in a more formal, report-like document. st2article() might have a slight speed advantage for shorter development cycle and simpler presentation. See details.

st2article(
  ...,
  .list = NULL,
  ntex = 1,
  stem = "view-st2article",
  output_dir = tempdir(),
  template = NULL,
  margin = c("2.54cm", "3cm"),
  caption = NULL,
  dry_run = FALSE,
  stdout = FALSE,
  show_pdf = TRUE
)

st2report(
  ...,
  .list = NULL,
  template = "report.tex",
  caption = Lorem,
  stem = "view-st2report"
)

Arguments

...

stable objects

.list

a list of stable objects

ntex

number of times to build the pdf file

stem

name for the article file, without extension

output_dir

the output directory for the rendered pdf file

template

an optional template for rendering the article; this normally shouldn't be used

margin

the page margins; this must be a character vector of length 1 or 2 specifying the page margins; if length is 1, the data will be recycled into the second position (e.g. equal margins left/right and top/bottom); if length is 2, use the first position to set left & right margins and the second position to set top & bottom margins; when specifying the margin size, include both the number and the unit (e.g. 3cm or 1in; you must enter the unit and the input must be character)

caption

placeholder text to be included as a caption; this text will be used for every table that is passed in; this isn't intended to be the actual caption for the table, but just placeholder text as you preview the appearance of the table

dry_run

if TRUE, then the document and table code are returned (visibly) and no attempt is made to try to pass the document through pdflatex

stdout

passed to system2(); by default, the pdflatex build output is suppressed; if you are having difficulty generating a pdf document, set stdout = "" and you'll see the output in the R console

show_pdf

if TRUE, then the rendered pdf file will be opened using fs::file_show()

Value

If dry_run is FALSE, then a list (invisible) containing the document template as doc and the table data as tables. If dry_run is TRUE, then the doc and tables are returned visibly (see dry_run argument).

A list of the table inputs, invisibly.

Details

This is experimental. Pass in either stable or stable_long objects, and st2article() or st2report() will write the output to temporary file and render the collection of tables in a pdf document without using Rmarkdown or pandoc. The rendering is accomplished through system call to pdflatex.

A working tex distribution is required to run this function.It is important to review the different latex dependencies in the document template. It is assumed that all of these dependencies are available. See examples below for code to open the template for review.

This function requires pdflatex to be installed and in your path to build the document. Run system2("pdflatex", "-v") to see if pdflatex properly installed.

This function requires specific packages to be available. Review the tex template files in /inst/article for a complete specification of the requirements. If a requirement is not available, the document will not build.

To render a table in landscape environment, pass the stable object through as_lscape.

Examples

template_file <- system.file("tex", "article.tex", package = "pmtables") template_contents <- readLines(template_file) template_file <- system.file("tex", "report.tex", package = "pmtables") template_contents <- readLines(template_file) if (FALSE) { tab <- stable(ptdata()) pmtables::st2article(tab) }