R/fao_plain.R

Defines functions fao_plain

#' @export
fao_plain <- function(keep_tex = TRUE,
                              includes = NULL){
  template <- system.file("rmarkdown", "templates", "fao_plain",
                          "resources", "template.tex",
                          package = "faodoc")
  base <- rmarkdown::pdf_document(template = template,
                                  keep_tex = keep_tex,
                                  includes = includes,
                                  highlight = "tango",
                                  pandoc_args = c("--latex-engine=xelatex"))

  # Mostly copied from knitr::render_sweave
  base$knitr$opts_knit$out.format <- "sweave"

  base$knitr$opts_chunk$prompt <- TRUE
  base$knitr$opts_chunk$comment <- NA
  base$knitr$opts_chunk$highlight <- FALSE
  #
  # hook_chunk <- function(x, options) {
  #   if (knitr:::output_asis(x, options)) return(x)
  #   paste0('\\begin{CodeChunk}\n', x, '\\end{CodeChunk}')
  # }
  # hook_input <- function(x, options) {
  #   paste0(c('\\begin{CodeInput}', x, '\\end{CodeInput}', ''),
  #          collapse = '\n')
  # }
  # hook_output <- function(x, options) {
  #   paste0('\\begin{CodeOutput}\n', x, '\\end{CodeOutput}\n')
  # }
  #
  # base$knitr$knit_hooks$chunk   <- hook_chunk
  # base$knitr$knit_hooks$source  <- hook_input
  # base$knitr$knit_hooks$output  <- hook_output
  # base$knitr$knit_hooks$message <- hook_output
  # base$knitr$knit_hooks$warning <- hook_output
  # base$knitr$knit_hooks$plot <- knitr:::hook_plot_tex
  base
}
UNFAOstatistics/faodoc documentation built on June 3, 2017, 6:42 a.m.