diff --git a/NAMESPACE b/NAMESPACE index 509caefaf..135b0d3c5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,6 +17,7 @@ export(elsevier_article) export(frontiers_article) export(ieee_article) export(joss_article) +export(journals) export(jss_article) export(mdpi_article) export(mnras_article) diff --git a/NEWS.md b/NEWS.md index 6988c0766..eedb7604f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ rticles 0.15 --------------------------------------------------------------------- +- Add a new `journals()` function to list all available journal names. + - Template directory in package's `rmarkdown/templates` directory has been renamed from _journalname_article_ to _journalname_. To create a new document using `rmarkdown::draft`, only the _journalname_ should be provided, i.e `rmarkdown::draft("MyArticle.Rmd", template = "rjournal", package = "rticles")` - Improved the `rjournal_article()` format : `.tex`, `.R`, and PDF files with correct names are generated to match the author's guidelines, two affiliations is now supported for authors, the last author is separated by `and` when multiple authors are present, and the documentation has been improved on the help page `?rticles::rjournal_article` and in the skeleton document (thanks, @RLumSK, #286). diff --git a/R/utils.R b/R/utils.R index 9efe6a5a0..4c5c168bf 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,3 +1,21 @@ +#' List available journals +#' +#' The function [journals()] will list available journal names in the **rticles** +#' package. These names can be useful in two ways : +#' * You can add `_article` suffix to get the format (i.e [rjournal_article()]). +#' Only exception is for the [ctex()] format. +#' * You can use the name directly in the `template` argument of +#' [rmarkdown::draft()]. +#' +#' @return a vector with the journal names of format available in rticles +#' @export +#' @md +#' @examples +#' rticles::journals() +journals <- function() { + sort(dir(pkg_file("rmarkdown", "templates"))) +} + find_resource <- function(template, file = 'template.tex') { res <- pkg_file("rmarkdown", "templates", template, "resources", file) if (res == "") stop( diff --git a/README.md b/README.md index 31ef2d5d9..dfead0072 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ Currently included templates and their contributors are the following: | [The R Journal](https://journal.r-project.org/) | | | `rjournal_article()` | +You can also get the list of available journal names with `rticles::journals()`. + Under the hood, LaTeX templates are used to ensure that documents conform precisely to submission standards. At the same time, composition and formatting can be done using lightweight [markdown](https://rmarkdown.rstudio.com/authoring_basics.html) syntax, and R code and its output can be seamlessly included using [knitr](https://yihui.name/knitr/). Using **rticles** requires the prerequisites described below. You can get most of these automatically by installing the latest release of RStudio (instructions for using **rticles** without RStudio are also provided). diff --git a/man/journals.Rd b/man/journals.Rd new file mode 100644 index 000000000..69846349a --- /dev/null +++ b/man/journals.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{journals} +\alias{journals} +\title{List available journals} +\usage{ +journals() +} +\value{ +a vector with the journal names of format available in rticles +} +\description{ +The function \code{\link[=journals]{journals()}} will list available journal names in the \strong{rticles} +package. These names can be useful in two ways : +\itemize{ +\item You can add \verb{_article} suffix to get the format (i.e \code{\link[=rjournal_article]{rjournal_article()}}). +Only exception is for the \code{\link[=ctex]{ctex()}} format. +\item You can use the name directly in the \code{template} argument of +\code{\link[rmarkdown:draft]{rmarkdown::draft()}}. +} +} +\examples{ +rticles::journals() +} diff --git a/tests/testit/test-utils.R b/tests/testit/test-utils.R index a7b1577be..cfe8330ac 100644 --- a/tests/testit/test-utils.R +++ b/tests/testit/test-utils.R @@ -27,3 +27,9 @@ assert("last author is prepend with and ", { unmodified <- c("\\author{John, Bob}", "some text", "\\author{Mary, Dany}") (suppressWarnings(post_process_authors(unmodified)) %==% unmodified) }) + +assert("all journals are listed and have a template folder", { + all <- grep("_article$|ctex", getNamespaceExports("rticles"), value = TRUE) + all <- gsub("_article$", "", all) + journals() %==% sort(all) +})