Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Dec 11, 2024
2 parents 8892447 + 56f0414 commit d3f16b9
Show file tree
Hide file tree
Showing 74 changed files with 11,215 additions and 1,698 deletions.
4 changes: 1 addition & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ You can contribute in many ways:

1. [Fork](https://github.com/rstudio/rticles/fork) the repository and make your changes in a new branch specific to the PR. It is ok to edit a file in this repository using the `Edit` button on Github if the change is simple enough.

2. For significant changes (e.g not required for fixing typos), ensure that you have signed the [individual](https://www.rstudio.com/wp-content/uploads/2014/06/rstudioindividualcontributoragreement.pdf) or [corporate](https://www.rstudio.com/wp-content/uploads/2014/06/rstudiocorporatecontributoragreement.pdf) contributor agreement as appropriate. You can send the signed copy to <jj@posit.co>.
2. For significant changes (e.g not required for fixing typos), ensure that you have signed the [individual](https://posit.co/wp-content/uploads/2023/04/2023-03-13_TC_Indiv_contrib_agreement.pdf) or [corporate](https://posit.co/wp-content/uploads/2023/04/2023-03-13_TC_Corp_contrib_agreement.pdf) contributor agreement as appropriate. You can send the signed copy to <contribute@posit.co>.

3. Submit the [pull request](https://help.github.com/articles/using-pull-requests). It is ok to submit as draft if you are still working on it but would like some feedback from us. It always good to share in the open that you are working on it.

4. You will be asked to check that you're PR meets some requirements. See the [PR template](https://pkgs.rstudio.com/rticles/PULL_REQUEST_TEMPLATE.html).

We'll try to be as responsive as possible in reviewing and accepting pull requests. Appreciate your contributions very much!
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

To contribute a new article template to this package, please make sure you have done the following things (note that `journalname_article` below is only an example name):

- [ ] This project uses a Contributor Licence Agreement (CLA) that you'll be asked to sign when opening a PR. This is required for a significant pull request (it is fine not to sign it if a PR is only intended to fix a few typos). Unless you have done it in any other RStudio / Posit projects before, sign the individual or corporate contributor agreement as appropriate. You can send the signed copy to <jj@posit.co>.
- [ ] This project uses a Contributor Licence Agreement (CLA) that you'll be asked to sign when opening a PR. This is required for a significant pull request (it is fine not to sign it if a PR is only intended to fix a few typos). Unless you have done it in any other RStudio / Posit projects before, sign the individual or corporate contributor agreement as appropriate. You can send the signed copy to <contribute@posit.co>.

- [ ] Add the `journalname_article()` function to `R/article.R` if the output format is simple enough, otherwise create a separate `R/journalname_article.R`.

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
matrix:
config:
# testing R release with last shipped pandoc version in RStudio IDE and new pandoc
- {os: windows-latest, pandoc: '3.1.9', r: 'release'}
- {os: macOS-latest, pandoc: '3.1.9', r: 'release'}
- {os: windows-latest, pandoc: '3.5', r: 'release'}
- {os: macOS-latest, pandoc: '3.5', r: 'release'}
- {os: ubuntu-latest, pandoc: 'devel', r: 'release'}
# testing older pandoc versions
- {os: ubuntu-latest, pandoc: '3.2.1', r: 'release'} # special \pandocbounded change
- {os: ubuntu-latest, pandoc: '3.1.7', r: 'release'} # special citeproc change
- {os: ubuntu-latest, pandoc: '2.19.2', r: 'release'}
- {os: ubuntu-latest, pandoc: '2.18', r: 'release'}
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: rticles
Title: Article Formats for R Markdown
Version: 0.27.3
Version: 0.27.7
Authors@R: c(
person("JJ", "Allaire", , "[email protected]", role = "aut"),
person("Yihui", "Xie", , "[email protected]", role = "aut",
Expand Down Expand Up @@ -110,5 +110,5 @@ Config/Needs/website: magick, pdftools, gifski, tidyverse/tidytemplate,
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
SystemRequirements: GNU make
16 changes: 14 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# rticles (development version)

- Fix `springer_article()` skeleton: It now uses `equal_contribution` in author field (thanks, @nielsbock, #568).
- Updaye `springer_aticle()` template to version 3 (December 2023):
- Update `springer_aticle()` template to version 3 (December 2023):
- BREAKING CHANGE: sn-mathphys.bst has been split into Numbered and Author year style namely `sn-mathphys-num.bst` and `sn-mathphys-ay.bst` respectively. Skeleton has been updated.
If you have existing article, you need to use `sn-mathphys-num` or `sn-mathphys-ay` option now, instead of `sn-mathphys`.
- Update all templates to work with Pandoc 3.2.1 by adding the definition of new `\pandocbounded` command used by Pandoc's LaTeX writers (see more at https://github.com/jgm/pandoc/releases/tag/3.2.1 and https://github.com/jgm/pandoc/issues/9660) (#571, #576).

- Update `mdpi_article()` to latest version of September 2024 (thanks, @nielsbock, #573, #580).

- Update `ams_article()` to latest version 6.1 with some breaking changes:
- Pandoc v2.10 is required with the template now
- Removed metadata no more used :
- `journal`, `layout`, `exauthors`, `author1`, `author2`, `currentaddress`, `affiliation`)
- Authors related variable are now `authors` and `affiliations` fields which accept multi authors. See the new skeleton by creating new template with `rmarkdown::draft("Untiltle.Rmd", "ams", "rticles")`.
- Only `natbib` is supported now in `citation_package`
- Some knitr options are made default in the format: `fig.path = ""`, `out.extra = ""`, `echo = FALSE`. They can be overriden in the document.
- Specific markdown syntax are available in template for `acknowledgments`, `datastatement`, `appendix`. See the new skeleton by creating new template with `rmarkdown::draft("Untiltle.Rmd", "ams", "rticles")`.

# rticles 0.27

Expand Down Expand Up @@ -294,7 +306,7 @@ fix for the LaTeX problem sanitized with the last `rticles` update (thanks, @RLu

- Fixed `elsevier_article()` template so that chunk option `out.width` can be set (thanks, @EddieItelman, #300).

- Fixed `pnas_journal()` skeleton to show how correctly add `corresponding_author` and `equal_author` (thanks, @EddieItelman, #299).
- Fixed `pnas_article()` skeleton to show how correctly add `corresponding_author` and `equal_author` (thanks, @EddieItelman, #299).

- Added article template for journal *Bioinformatics* (thanks, @ShixiangWang, #297).

Expand Down
61 changes: 61 additions & 0 deletions R/ams_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#' American Meteorological Society journals format.
#'
#' Format for creating submissions to American Meteorological Society journals.
#'
#' @inheritParams rmarkdown::pdf_document
#' @param citation_package only natbib is supported with this template.
#' @param ... Additional arguments to [rmarkdown::pdf_document()]. **Note**: `extra_dependencies` are not
#' allowed as Copernicus does not support additional packages included via \code{\\usepackage{}}.
#'
#' @return An R Markdown output format.
#' @details This was adapted from
#' <https://www.ametsoc.org/index.cfm/ams/publications/author-information/latex-author-info/>.
#'
#' The template require some default knitr option to be change:
#'
#' * `echo = FALSE` as no R code should be shown
#' * `fig.path = ""` as all directory paths need to be removed from figure names
#' * `out.extra = ""` to force figure labels with knitr
#'
#' @examples
#' \dontrun{
#' library("rmarkdown")
#' draft("MyArticle.Rmd", template = "ams", package = "rticles")
#' render("MyArticle/MyArticle.Rmd")
#' }
#' @export
ams_article <- function(..., keep_tex = TRUE, citation_package = "natbib", md_extensions = c("-autolink_bare_uris", "-auto_identifiers"), pandoc_args = NULL) {

rmarkdown::pandoc_available('2.10', TRUE)

if (citation_package != "natbib") {
stop("AMS template supports only `natbib` for citation processing.")
}

pandoc_args <- c(
pandoc_args,
"--lua-filter", find_resource("ams", "ams.lua")
)

base <- pdf_document_format(
"ams", keep_tex = keep_tex, md_extensions = md_extensions, citation_package = 'natbib',
pandoc_args = pandoc_args, ...
)
pre_knit <- base$pre_knit
base$pre_knit <- function(input, metadata, ...) {
if (is.function(pre_knit)) pre_knit(input, metadata, ...)
old_meta <- c("journal", "layout", "exauthors", "author1", "author2", "currentaddress", "affiliation")
# check old arg
metadata_used <- old_meta %in% names(metadata)
if (any(metadata_used)) {
warning("You are probably using an old version of the template - please update to new skeleton or keep using rticles 0.27.", immediate. = TRUE, call. = FALSE)
warning("Some metadata are no more used in new AMS template: ", knitr::combine_words(old_meta[metadata_used]), ". They will be ignored.", immediate. = TRUE, call. = FALSE)
}
}
base$knitr$opts_chunk <- merge_list(base$knitr$opts_chunk, list(
fig.path = "", # AMS required
out.extra = "", # To force figure labels
echo = FALSE # Don't show R code
))
return(base)
}
111 changes: 0 additions & 111 deletions R/article.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@ amq_article <- function(..., latex_engine = "xelatex", keep_tex = TRUE,
)
}

#' @section `ams_article`: Format for creating an American Meteorological
#' Society (AMS) Journal articles. Adapted from
#' <https://www.ametsoc.org/ams/index.cfm/publications/authors/journal-and-bams-authors/author-resources/latex-author-info/>.
#' @export
#' @rdname article
ams_article <- function(..., keep_tex = TRUE,
md_extensions = c("-autolink_bare_uris")) {
pdf_document_format(
"ams",
keep_tex = keep_tex, md_extensions = md_extensions, ...
)
}

#' @section `asa_article`: This format was adapted from The American
#' Statistician (TAS) format, but it should be fairly consistent across
#' American Statistical Association (ASA) journals.
Expand Down Expand Up @@ -366,104 +353,6 @@ jedm_article <- function(..., keep_tex = TRUE, citation_package = "natbib") {
)
}

#' @section `mdpi_article`: Format for creating submissions to
#' Multidisciplinary Digital Publishing Institute (MDPI) journals. Adapted
#' from <https://www.mdpi.com/authors/latex>.
#'
#' Possible arguments for the YAML header are:
#' * `title` title of the manuscript
#' * `author` list of authors, containing `name`, `affil`, and `orcid` (optional)
#' * `affiliation` list containing `num`, `address`, and `email` for defining `author` affiliations
#' * `authorcitation` string with last name and first intial of authors as expected to be shown in a reference
#' * `firstnote` can include `firstnote` through `eightnote` that correspond to footnote marks in `affil`
#' * `correspondence` contact information of the corresponding author
#' * `journal` short name (case sensitive) of the journal, see template for options
#' * `type` usually "article" but see template for options
#' * `status` usually "submit"
#' * `simplesummary` optional, may depend on specific journal
#' * `abstract` abstract, limited to 200 words
#' * `keywords` 3 to 10 keywords seperated with a semicolon
#' * `acknowledgement` acknowledgement backmatter (optional)
#' * `authorcontributions` report authorship contributions (optional)
#' * `funding` research funding statement
#' * `institutionalreview` IRB statements (optional)
#' * `informedconsent` Informed consent statements for human research (optional)
#' * `dataavailability` Links to datasets or archives (optional)
#' * `conflictsofinterest` Conflict of interest statement (see journal instructions)
#' * `sampleavailability` Sample availability statement (optional)
#' * `supplementary` Supplementary data statement, see template for example (optional)
#' * `abbreviations` list of abbreviations containing `short` and `long`
#' * `bibliography` BibTeX `.bib` file
#' * `appendix` name of appendix tex file
#' * `endnote` boolean, if `TRUE` will print list of endnotes if included in text (optional)
#' * `header-includes`: custom additions to the header, before the `\begin{document}` statement
#' * `include-after`: for including additional LaTeX code before the `\end{document}` statement
#' @export
#' @rdname article
mdpi_article <- function(..., keep_tex = TRUE, latex_engine = "pdflatex", pandoc_args = NULL, citation_package = "natbib") {

# check all arguments for format's default
if (citation_package != "natbib") {
stop("MDPI template only supports 'natbib' for citation processing.")
}

## check if latex engine is pdflatex or xelatex
if(!latex_engine %in% c("pdflatex", "xelatex")) {
stop("`latex_engine` must be one of 'pdflatex' or 'xelatex' when using the MDPI template.")
}

## check location of mdpi.cls file (new versions are in subfolder)
## to ensure compatibility with old versions
cls_loc <- if(file.exists("mdpi.cls")) "mdpi" else "Definitions/mdpi"
pandoc_args <- c(pandoc_args, rmarkdown::pandoc_variable_arg("cls", cls_loc))

## if latex engine is pdflatex, mdpi class argument must be pdftex
if(latex_engine == "pdflatex") {
pandoc_args <- c(pandoc_args, rmarkdown::pandoc_variable_arg("pdftex", "pdftex"))
}

base <- pdf_document_format(
"mdpi",
keep_tex = keep_tex,
citation_package = "natbib",
latex_engine = latex_engine,
pandoc_args = pandoc_args,
...
)

base_pre_processor <- base$pre_processor

## pre_processor checks if author metadata > 1 and uses moreauthors mdpi class
## argument
mdpi_pre_processor <- function(metadata,
input_file,
runtime,
knit_meta,
files_dir,
output_dir) {
args <- c(
# run the base prepocessor of the format
if (is.function(base_pre_processor)) {
base_pre_processor(
metadata, input_file, runtime, knit_meta, files_dir, output_dir
)
},
# Set a variable based on metadata field
if (!is.null(metadata$author)) {
if (length(metadata$author) > 1) {
rmarkdown::pandoc_variable_arg("multipleauthors", "moreauthors")
} else {
rmarkdown::pandoc_variable_arg("multipleauthors", "oneauthor")
}
}
)
args
}

base$pre_processor <- mdpi_pre_processor
base
}

#' @section `mnras_article`: Format for creating an Monthly Notices of
#' Royal Astronomical Society (MNRAS) Journal articles. Adapted from
#' <https://ras.ac.uk>.
Expand Down
Loading

0 comments on commit d3f16b9

Please sign in to comment.