Skip to content

Commit

Permalink
remove the base_format argument from peerj_article() (#127) and `…
Browse files Browse the repository at this point in the history
…copernicus_article()` (#172)
  • Loading branch information
yihui committed Mar 14, 2019
1 parent e35d144 commit 24d069f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 50 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------------------------------------------------------

Expand Down
21 changes: 6 additions & 15 deletions R/copernicus_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
22 changes: 6 additions & 16 deletions R/peerj_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
#'
Expand All @@ -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")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
---


Expand Down
7 changes: 1 addition & 6 deletions man/copernicus_article.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions man/peerj_article.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 24d069f

Please sign in to comment.