Learn R Programming

R3port (version 0.2.5)

ltx_doc: Prints latex code for a table, listing, plot, or text to a a file or console

Description

This function makes a latex document using output generated with functions in the R3port package or any other latex code available as vector. Basically it adds a preamble to a tex file and let's the user select various options to customize the output.

Usage

ltx_doc(
  text,
  out = NULL,
  template = paste0(system.file(package = "R3port"), "/simple.tex"),
  rendlist,
  orientation = "landscape",
  rtitle = "report",
  compile = TRUE,
  show = TRUE
)

Value

The function returns a latex file (or writes output to console)

Arguments

text

character vector to be placed within latex document

out

filename for the output latex file (if NULL it will print to console)

template

file name of the template file to use (see examples how templates can be used/adapted)

rendlist

a render list to be used for the template file (see (see whisker-package))

orientation

string indicating the page orientation (can be either "landscape" or "portrait")

rtitle

string indicating the title of the output document

compile

logical indicating if the tex file should be compiled (using tools::texi2dvi)

show

logical indicating if the resulting pdf file from the compiled tex file should be opened when created

See Also

html_doc

Examples

Run this code

if (FALSE) {
  txt <- "\\section{example}"
  tbl <- "\\begin{tabular}{|l|c|r|} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ \\end{tabular}"
  add <- "\\\\ Including some additional text"
  ltx_doc(c(txt,tbl,add),out=paste0(tempfile(),".tex"),show=FALSE)

  # You can use xtable (and any other packages that output tex)
  library(xtable)
  data(Theoph)
  xtbl <- print(xtable(Theoph),tabular.environment="longtable",floating=FALSE,print.results=FALSE)
  ltx_doc(xtbl,out=tempfile(fileext = ".tex"))

}

Run the code above in your browser using DataLab