Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- rticles now requires rmarkdown 2.32 or later and Pandoc 2.8 or later, matching rmarkdown's updated minimum Pandoc version ([rstudio/rmarkdown#2623](https://github.com/rstudio/rmarkdown/pull/2623)).

- `agu_article()` now uses Pandoc citeproc with the American Geophysical Union CSL style by default. Existing drafts containing only `agujournal2018.cls` must explicitly set `citation_package: natbib`; the format warns when the selected class and citation backend are incompatible (#606).

- Update `springer_article()` 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`.
Expand Down Expand Up @@ -38,6 +40,8 @@ supported by the `copernicus.cls`, and fix an issue where the section headers we

## MINOR CHANGES

- Update `agu_article()` to AGU's September 2025 distribution of `agujournal2019.cls`, current manuscript guidance, and external TrackChanges setup (#606).

- Fix `agu_article()` table rendering with recent LaTeX distributions by using the text-mode table centering helper when available (#606).

- Fix `biometrics_article()` rendering with LaTeX 2026 by preserving the LaTeX kernel's matching `\endtabular` implementation.
Expand Down
91 changes: 86 additions & 5 deletions R/article.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,100 @@ aea_article <- function(..., keep_tex = TRUE,
)
}

#' @section `agu_article`: Format for creating a American Geophysical Union
#' (AGU) article. Adapted from
#' <https://www.agu.org/publications>.
#' @section `agu_article`: Format for creating an American Geophysical Union
#' (AGU) article. Adapted from AGU's September 2025 LaTeX distribution of
#' `agujournal2019.cls` and the official [LaTeX submission
#' guidelines](https://www.agu.org/publications/authors/journals/latex-submissions).
#'
#' The default `citation_package = "default"` uses Pandoc citeproc with
#' the American Geophysical Union CSL style, following the approach used by
#' the Quarto AGU journal format. Use Markdown citation syntax in current
#' drafts.
#'
#' New drafts include `agujournal2019.cls`. Existing drafts that retain only
#' a project-local `agujournal2018.cls` remain supported but must explicitly
#' set `citation_package = "natbib"`. The format warns when the selected
#' class and citation backend are incompatible. If both classes are present,
#' the current 2019 class is used.
#' @export
#' @rdname article
agu_article <- function(..., keep_tex = TRUE,
citation_package = "natbib", highlight = NULL,
citation_package = "default", highlight = NULL,
md_extensions = c("-autolink_bare_uris", "-auto_identifiers")) {
pdf_document_format(
format <- pdf_document_format(
"agu",
keep_tex = keep_tex, highlight = highlight,
citation_package = citation_package, md_extensions = md_extensions, ...
)

pre_processor <- format$pre_processor
format$pre_processor <- function(metadata, input_file, runtime, knit_meta,
files_dir, output_dir) {
input_dir <- dirname(input_file)
legacy_class <- file.path(input_dir, "agujournal2018.cls")
current_class <- file.path(input_dir, "agujournal2019.cls")
has_legacy_class <- file.exists(legacy_class)
has_current_class <- file.exists(current_class)
use_current_class <- !has_legacy_class || has_current_class

if (!use_current_class && citation_package != "natbib") {
warn_once(
"rticles.warn_agu_2018_citations",
"Detected only 'agujournal2018.cls', which expects ",
"`citation_package = \"natbib\"`. The selected '",
citation_package,
"' backend is unsupported for legacy raw \\citep and \\citet ",
"commands. Set natbib explicitly or update the draft to the 2019 class."
)
} else if (!use_current_class) {
warn_once(
"rticles.warn_agu_2018",
"Detected 'agujournal2018.cls' next to the input file. ",
"This class remains supported for backward compatibility, but the ",
"article should be updated from the current `rticles::agu_article()` ",
"template to use 'agujournal2019.cls' and current AGU guidance."
)
} else {
if (has_legacy_class && has_current_class) {
warn_once(
"rticles.warn_agu_both_classes",
"Detected both 'agujournal2018.cls' and 'agujournal2019.cls' next to ",
"the input file. The AGU template will use 'agujournal2019.cls'; you ",
"may remove the unused 'agujournal2018.cls' file."
)
}
if (citation_package != "default") {
warn_once(
"rticles.warn_agu_2019_citations",
"The selected 2019 AGU class supports `citation_package = ",
"\"default\"` with citeproc and the AGU CSL style. The selected '",
citation_package,
"' backend is unsupported; the 2019 class does not provide natbib ",
"citation commands."
)
}
}

c(
if (is.function(pre_processor)) {
pre_processor(
metadata, input_file, runtime, knit_meta, files_dir, output_dir
)
},
if (use_current_class) {
rmarkdown::pandoc_variable_arg("rticles-agu-2019")
},
if (citation_package == "default" && is.null(metadata$csl)) {
c(
"--csl",
rmarkdown::pandoc_path_arg(pkg_file_template(
"agu", "skeleton", "american-geophysical-union.csl"
))
)
}
)
}
format
}

#' @section `amq_article`: Ce format a été adapté du format du bulletin de
Expand Down
61 changes: 20 additions & 41 deletions inst/rmarkdown/templates/agu/resources/template.tex
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
%% March 2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% AGUJournalTemplate.tex: this template file is for articles formatted with LaTeX
% AGU article template adapted from the September 2025 distribution of
% agujournal2019.cls. Existing rticles drafts may retain agujournal2018.cls.
%
% This file includes commands and instructions
% given in the order necessary to produce a final output that will
% satisfy AGU requirements, including customized APA reference formatting.
%
% You may copy this file and give it your
% article name, and enter your text.
%
%
% Step 1: Set the \documentclass
%
% There are two options for article format:
%
% PLEASE USE THE DRAFT OPTION TO SUBMIT YOUR PAPERS.
% The draft option produces double spaced output.
%

%% To submit your paper:
% Prefer the current class deterministically when both local classes exist.
$if(rticles-agu-2019)$
\documentclass[$for(classoption)$$classoption$$sep$,$endfor$]{agujournal2019}

% The 2019 class leaves revision packages to the document. The 2018 class
% already loads trackchanges and ulem, so reloading them would clash.
\usepackage[inline]{trackchanges}
\usepackage{soul}
$else$
\documentclass[$for(classoption)$$classoption$$sep$,$endfor$]{agujournal2018}
\usepackage{apacite}
\usepackage{url} %this package should fix any errors with URLs in refs.
%%%%%%%
% As of 2018 we recommend use of the TrackChanges package to mark revisions.
% The trackchanges package adds five new LaTeX commands:
%
% \note[editor]{The note}
% \annote[editor]{Text to annotate}{The note}
% \add[editor]{Text to add}
% \remove[editor]{Text to remove}
% \change[editor]{Text to remove}{Text to add}
%
% complete documentation is here: http://trackchanges.sourceforge.net/
%%%%%%%
$endif$


%% Enter journal name below.
Expand Down Expand Up @@ -113,6 +92,8 @@

$if(csl-refs)$
% Pandoc citation processing
\providecommand{\phantomsection}{}
\providecommand{\hypertarget}[2]{#2}
$if(pandoc318)$
%From Pandoc 3.1.8
% definitions for citeproc citations
Expand Down Expand Up @@ -281,13 +262,13 @@

% List up to three key points (at least one is required)
% Key Points summarize the main points and conclusions of the article
% Each must be 100 characters or less with no special characters or punctuation
% Each must be 140 characters or fewer with no special characters or punctuation

% Example:
% \begin{keypoints}
% \item List up to three key points (at least one is required)
% \item Key Points summarize the main points and conclusions of the article
% \item Each must be 100 characters or less with no special characters or punctuation
% \item Each must be 140 characters or fewer with no special characters or punctuation
% \end{keypoints}

\begin{keypoints}
Expand All @@ -312,16 +293,14 @@
$abstract$
\end{abstract}
$if(plain_language_summary)$
\noindent{\bf Plain language summary}\vskip-\parskip

\noindent{$plain_language_summary$}
\vskip18pt
\section*{Plain Language Summary}
$plain_language_summary$
$endif$
$body$

$if(bibliography)$
$if(natbib)$$if(bibliography)$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$
$endif$$endif$

$for(include-after)$
$include-after$
Expand Down
Loading
Loading