peerj_article.R 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #' PeerJ journal format.
  2. #'
  3. #' Format for creating submissions to The PeerJ.
  4. #'
  5. #' @inheritParams rmarkdown::pdf_document
  6. #' @param ... Additional arguments to \code{base_format}
  7. #' @param base_format The function to use for the base format of the article.
  8. #' By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's
  9. #' cross-referencing feature, this can be set to \code{bookdown::pdf_document2}
  10. #'
  11. #' @return R Markdown output format to pass to
  12. #' \code{\link[rmarkdown:render]{render}}
  13. #'
  14. #' @details This was adapted from the
  15. #' \href{https://www.overleaf.com/latex/templates/latex-template-for-peerj-journal-and-pre-print-submissions/ptdwfrqxqzbn}{PeerJ Overleaf Template}.
  16. #'
  17. #' @note If you use \code{rmarkdown::pdf_document()}, all internal references
  18. #' (i.e. tables and figures) must use \code{\\ref\{\}} whereas with
  19. #' \code{bookdown::pdf_document2()}, you can additionally use \code{\\@@ref()}.
  20. #'
  21. #' @examples
  22. #'
  23. #' \dontrun{
  24. #' library(rmarkdown)
  25. #' draft("MyArticle.Rmd", template = "peerj_article", package = "rticles")
  26. #' }
  27. #'
  28. #' @export
  29. peerj_article <- function(..., keep_tex = TRUE, citation_package = "none",
  30. base_format = rmarkdown::pdf_document) {
  31. if (inherits(base_format, "character")){
  32. FMT <- eval(parse(text = base_format))
  33. } else {
  34. FMT <- match.fun(base_format)
  35. }
  36. out <- FMT(...,
  37. citation_package = citation_package,
  38. keep_tex = keep_tex,
  39. template = find_resource("peerj_article", "template.tex"))
  40. }