##' @export
excel2pdf <- function(outfile, landscape = TRUE,...){
if (landscape == TRUE){
preamble = '\\documentclass[12pt,a4paper,landscape]{article}'
} else {
preamble = '\\documentclass[12pt,a4paper]{article}'
}
DIR.DATA <- "/Users/jankocizel/Documents/Dropbox/Projects/PhD Thesis/R/PACKAGES/texutils/inst/test_output"
template <- readLines(system.file('./latex_templates/latex_article.tex',package = 'texutils'))
excel2tex(outfile = outfile,...) ->
out
list(
preamble = preamble,
content = out
) ->
info
whisker.render(template, info) ->
out
if (!is.null(outfile)){
out %>>%
writeLines(con = sprintf(fmt = "%s", outfile))
cat(sprintf(fmt = "File written to: %s.\n", outfile))
} else {
outfile = file.path(DIR.DATA,
sprintf("%s Test.tex",Sys.time()))
out %>>%
writeLines(con = sprintf(fmt = "%s", outfile))
cat(sprintf(fmt = "File written to: %s.\n", outfile))
}
wd.old <- getwd()
setwd(dirname(outfile))
system(sprintf('pdflatex "%s"',basename(outfile)))
system(sprintf('pdflatex "%s"',basename(outfile)))
outfile.pdf <- gsub("\\.tex$","\\.pdf",outfile)
system(sprintf('open "%s"',outfile.pdf))
setwd(wd.old)
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.