From 24d069f4cab715ff202580ce817f3812d5bf9f93 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Thu, 14 Mar 2019 15:24:22 -0500 Subject: [PATCH] remove the `base_format` argument from `peerj_article()` (#127) and `copernicus_article()` (#172) --- DESCRIPTION | 2 +- NEWS | 2 ++ R/copernicus_article.R | 21 +++++------------- R/peerj_article.R | 22 +++++-------------- .../copernicus_article/skeleton/skeleton.Rmd | 5 +++-- .../peerj_article/skeleton/skeleton.Rmd | 7 +++--- man/copernicus_article.Rd | 7 +----- man/peerj_article.Rd | 9 ++------ 8 files changed, 25 insertions(+), 50 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b571a47e4..c3cb8ade1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rticles Type: Package Title: Article Formats for R Markdown -Version: 0.6.2 +Version: 0.6.3 Authors@R: c( person("JJ", "Allaire", role = "aut", email = "jj@rstudio.com"), person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), diff --git a/NEWS b/NEWS index 824a80432..12576250d 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ rticles 0.7 - Added an argument `pandoc_args` to `ieee_article()` so that users can pass custom Pandoc arguments. This also makes it work with `bookdown::pdf_book()` (thanks, @espinielli, #206). +- The `base_format` argument has been removed from `peerj_article()` and `copernicus_article()`. This argument was originally added mainly for supporting `bookdown::pdf_book()`, but you should really pass these formats to the `base_format` argument of `bookdown::pdf_book` instead of the other way around. + rticles 0.6 --------------------------------------------------------------------- diff --git a/R/copernicus_article.R b/R/copernicus_article.R index d731dbada..c60315732 100644 --- a/R/copernicus_article.R +++ b/R/copernicus_article.R @@ -3,10 +3,7 @@ #' Format for creating submissions to Copernicus journals. #' #' @inheritParams rmarkdown::pdf_document -#' @param ... Additional arguments to \code{base_format} -#' @param base_format The function to use for the base format of the article. -#' By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's -#' cross-referencing feature, this can be set to \code{bookdown::pdf_document2} +#' @param ... Additional arguments to \code{rmarkdown::pdf_document()}. #' @param journal_name A regular expression to filter the by the journal name, see \code{pattern} in \code{\link[base]{grep}}; defaults to \code{*}. #' #' @return R Markdown output format to pass to @@ -56,21 +53,15 @@ copernicus_article <- function(..., keep_tex = TRUE, citation_package = "natbib", - base_format = rmarkdown::pdf_document, md_extensions = c( "-autolink_bare_uris", # disables automatic links, needed for plain email in \correspondence "-auto_identifiers" # disables \hypertarget commands )) { - if (is.character(base_format)) { - FMT <- eval(parse(text = base_format)) - } else { - FMT <- match.fun(base_format) - } - FMT(..., - citation_package = citation_package, - keep_tex = keep_tex, - md_extensions = md_extensions, - template = find_resource("copernicus_article", "template.tex")) + inherit_pdf_document( + ..., citation_package = citation_package, keep_tex = keep_tex, + md_extensions = md_extensions, + template = find_resource("copernicus_article", "template.tex") + ) } # quick dev shortcut for Ubuntu: click "Install and restart" then run: diff --git a/R/peerj_article.R b/R/peerj_article.R index eff6a17a8..4c52f3830 100644 --- a/R/peerj_article.R +++ b/R/peerj_article.R @@ -3,11 +3,7 @@ #' Format for creating submissions to The PeerJ. #' #' @inheritParams rmarkdown::pdf_document -#' @param ... Additional arguments to \code{base_format} -#' @param base_format The function to use for the base format of the article. -#' By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's -#' cross-referencing feature, this can be set to \code{bookdown::pdf_document2} -#' +#' @param ... Additional arguments to \code{rmarkdown::pdf_document()}. #' @return R Markdown output format to pass to #' \code{\link[rmarkdown:render]{render}} #' @@ -26,15 +22,9 @@ #' } #' #' @export -peerj_article <- function(..., keep_tex = TRUE, citation_package = "none", - base_format = rmarkdown::pdf_document) { - if (inherits(base_format, "character")){ - FMT <- eval(parse(text = base_format)) - } else { - FMT <- match.fun(base_format) - } - out <- FMT(..., - citation_package = citation_package, - keep_tex = keep_tex, - template = find_resource("peerj_article", "template.tex")) +peerj_article <- function(..., keep_tex = TRUE, citation_package = "none") { + inherit_pdf_document( + ..., citation_package = citation_package, keep_tex = keep_tex, + template = find_resource("peerj_article", "template.tex") + ) } diff --git a/inst/rmarkdown/templates/copernicus_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/copernicus_article/skeleton/skeleton.Rmd index a7f309901..93ca74277 100755 --- a/inst/rmarkdown/templates/copernicus_article/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/copernicus_article/skeleton/skeleton.Rmd @@ -64,8 +64,9 @@ appendix: | Please add `\clearpage` between each table and/or figure. Further guidelines on figures and tables can be found below. output: - rticles::copernicus_article: - base_format: rmarkdown::pdf_document + rticles::copernicus_article: default + bookdown::pdf_book: + base_format: rticles::copernicus_article # for using bookdown features like \@ref() --- \introduction diff --git a/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd index 41843ed47..d4d4f8698 100755 --- a/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd @@ -19,9 +19,10 @@ abstract: > header-includes: > \usepackage{lipsum} bibliography: sample.bib -output: - rticles::peerj_article: - base_format: rmarkdown::pdf_document # bookdown::pdf_document2 # for using \@ref() +output: + bookdown::pdf_book: + base_format: rticles::peerj_article # for using bookdown features like \@ref() + rticles::peerj_article: default --- diff --git a/man/copernicus_article.Rd b/man/copernicus_article.Rd index a2e803e82..fff99f2a4 100644 --- a/man/copernicus_article.Rd +++ b/man/copernicus_article.Rd @@ -6,23 +6,18 @@ \title{Copernicus journals format.} \usage{ copernicus_article(..., keep_tex = TRUE, citation_package = "natbib", - base_format = rmarkdown::pdf_document, md_extensions = c("-autolink_bare_uris", "-auto_identifiers")) copernicus_journal_abbreviations(journal_name = "*") } \arguments{ -\item{...}{Additional arguments to \code{base_format}} +\item{...}{Additional arguments to \code{rmarkdown::pdf_document()}.} \item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF} \item{citation_package}{The LaTeX package to process citations, \code{natbib} or \code{biblatex}. Use \code{none} if neither package is to be used.} -\item{base_format}{The function to use for the base format of the article. -By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's -cross-referencing feature, this can be set to \code{bookdown::pdf_document2}} - \item{md_extensions}{Markdown extensions to be added or removed from the default definition or R Markdown. See the \code{\link{rmarkdown_format}} for additional details.} diff --git a/man/peerj_article.Rd b/man/peerj_article.Rd index 53ab26393..42ba4f8b0 100644 --- a/man/peerj_article.Rd +++ b/man/peerj_article.Rd @@ -4,20 +4,15 @@ \alias{peerj_article} \title{PeerJ journal format.} \usage{ -peerj_article(..., keep_tex = TRUE, citation_package = "none", - base_format = rmarkdown::pdf_document) +peerj_article(..., keep_tex = TRUE, citation_package = "none") } \arguments{ -\item{...}{Additional arguments to \code{base_format}} +\item{...}{Additional arguments to \code{rmarkdown::pdf_document()}.} \item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF} \item{citation_package}{The LaTeX package to process citations, \code{natbib} or \code{biblatex}. Use \code{none} if neither package is to be used.} - -\item{base_format}{The function to use for the base format of the article. -By default, this is \code{rmarkdown::pdf_document}, but to use bookdown's -cross-referencing feature, this can be set to \code{bookdown::pdf_document2}} } \value{ R Markdown output format to pass to