Skip to content
Merged
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
2 changes: 1 addition & 1 deletion 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.13
Version: 0.27.14
Authors@R: c(
person("JJ", "Allaire", , "jj@posit.co", role = "aut"),
person("Yihui", "Xie", , "xie@yihui.name", role = "aut",
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ supported by the `copernicus.cls`, and fix an issue where the section headers we
- Added `\setlength{\emergencystretch}{3em}` to prevent overfull lines.
- Updated CSL citation helper commands (`\CSLBlock`, `\CSLLeftMargin`, `\CSLRightInline`) to match current Pandoc defaults, improving bibliography spacing and baseline alignment.

- Fix `oup_article(oup_version = 1)` rendering with the November 2025 update of `oup-authoring-template.cls` (v1.2) on CTAN, which removed the (undocumented) `\authormark` macro that the template was emitting for the running head. The block is now dropped from the template, matching OUP's own example file and current author manual: the running head is set via the optional argument of `\title` (`\title[short]{long}`), which is the documented mechanism in v1.2. Setting `authormark` in YAML is now ignored and emits a warning at render time (#603).

- Adapt all templates to new Pandoc 3.8.2.1 change regarding table counter definition (#595).

- Patch `WileyNDJ` template used in `sim_article()` to fix an issue with `etex` package not being useful anymore in recent LaTeX distributions (#593).
Expand Down
18 changes: 17 additions & 1 deletion R/oup_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ oup_article <- function( # Controls template to use. 1 for newer template.
}
}

pdf_document_format(
base <- pdf_document_format(
"oup_v1",
keep_tex = keep_tex,
md_extensions = md_extensions,
Expand All @@ -135,4 +135,20 @@ oup_article <- function( # Controls template to use. 1 for newer template.
number_sections = number_sections,
...
)

# Warn if YAML metadata still sets the removed `authormark` field
# (oup-authoring-template.cls v1.2, 2025-11-17, dropped the \authormark macro)
pre_knit <- base$pre_knit
base$pre_knit <- function(input, metadata, ...) {
if (is.function(pre_knit)) pre_knit(input, metadata, ...)
if ("authormark" %in% names(metadata)) {
warning(
"`oup_article(oup_version = 1)` now ignores the 'authormark' field in YAML header. ",
"The \\authormark macro was removed from oup-authoring-template.cls v1.2 (2025-11-17); ",
"running heads are now set from the optional short title argument of \\title.",
immediate. = TRUE, call. = FALSE
)
}
}
base
}
9 changes: 0 additions & 9 deletions inst/rmarkdown/templates/oup_v1/resources/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,6 @@
$endfor$
% Add author mark
$if(authormark)$
\authormark{$authormark$}
$elseif(author)$
\authormark{$for(author/first)$$it.name$$endfor$$if(author/rest/rest)$ et al.$else$$for(author/rest)$ \and $author.name$$endfor$$endif$}
$elseif(authors)$
\authormark{$for(authors/first)$$it.name$$endfor$$if(authors/rest/rest)$ et al.$else$$for(authors/rest)$ \and $authors.name$$endfor$$endif$}
$endif$
\received{Date}{0}{Year}
\revised{Date}{0}{Year}
\accepted{Date}{0}{Year}
Expand Down
36 changes: 36 additions & 0 deletions tests/testthat/helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
local_rmd_file <- function(..., .env = parent.frame()) {
path <- withr::local_tempfile(.local_envir = .env, fileext = ".Rmd")
xfun::write_utf8(c(...), path)
path
}

.render_and_read <- function(input, ...) {
skip_if_not_pandoc()
output_file <- withr::local_tempfile()
res <- rmarkdown::render(input, output_file = output_file, quiet = TRUE, ...)
xfun::read_utf8(res)
}

# Use to test pandoc availability or version lower than
skip_if_not_pandoc <- function(ver = NULL) {
if (!rmarkdown::pandoc_available(ver)) {
msg <- if (is.null(ver)) {
"Pandoc is not available"
} else {
sprintf("Version of Pandoc is lower than %s.", ver)
}
skip(msg)
}
}

# Use to test version greater than
skip_if_pandoc <- function(ver = NULL) {
if (rmarkdown::pandoc_available(ver)) {
msg <- if (is.null(ver)) {
"Pandoc is available"
} else {
sprintf("Version of Pandoc is greater than %s.", ver)
}
skip(msg)
}
}
49 changes: 49 additions & 0 deletions tests/testthat/test-oup_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
test_that("oup_article(oup_version = 1) warns when `authormark` is set in YAML", {
skip_if_not_pandoc("2.10")
fmt <- oup_article(oup_version = 1)
expect_warning(
fmt$pre_knit(input = "", metadata = list(authormark = "Anonymous et al.")),
regexp = "authormark"
)
})

test_that("oup_article(oup_version = 1) does not warn for unrelated metadata", {
skip_if_not_pandoc("2.10")
fmt <- oup_article(oup_version = 1)
expect_no_warning(
fmt$pre_knit(input = "", metadata = list(title = "A title"))
)
})

test_that("rmarkdown::render() actually invokes the pre_knit hook", {
# Guards against regressions where pre_knit stops being wired into the
# format returned by oup_article(): asserts the warning surfaces from a
# real (knit-only, no LaTeX) render of an Rmd whose YAML sets `authormark`.
skip_if_not_pandoc("2.10")
rmd <- withr::local_tempfile(fileext = ".Rmd")
xfun::write_utf8(
c(
"---",
"title: t",
"authormark: \"X et al.\"",
"output:",
" rticles::oup_article:",
" oup_version: 1",
"---",
"",
"Body."
),
rmd
)
expect_warning(
rmarkdown::render(rmd, quiet = TRUE, run_pandoc = FALSE),
regexp = "authormark"
)
})

test_that("oup_v1 template no longer emits \\authormark", {
tex <- xfun::read_utf8(
pkg_file_template("oup_v1", "resources", "template.tex")
)
expect_false(any(grepl("\\authormark", tex, fixed = TRUE)))
})
Loading