-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to all bibliography styles required by Taylor & Francis j…
…ournals (#581) Co-authored-by: Christophe Dervieux <[email protected]>
- Loading branch information
Showing
16 changed files
with
8,353 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.9 | ||
Version: 0.27.10 | ||
Authors@R: c( | ||
person("JJ", "Allaire", , "[email protected]", role = "aut"), | ||
person("Yihui", "Xie", , "[email protected]", role = "aut", | ||
|
@@ -79,7 +79,9 @@ Authors@R: c( | |
person("Dmytro", "Perepolkin", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0001-8558-6183", github = "dmi3kno")), | ||
person("Tom", "Palmer", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0003-4655-4511", github = "remlapmot")) | ||
comment = c(ORCID = "0000-0003-4655-4511", github = "remlapmot")), | ||
person("Rafael", "Laboissière", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-2180-9250", github = "rlaboiss")) | ||
) | ||
Description: A suite of custom R Markdown formats and templates for | ||
authoring journal articles and conference submissions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#' Taylor & Francis journals format | ||
#' | ||
#' Format for creating submissions to many Taylor & Francis journals. | ||
#' Adapted from: | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractAPALaTeX.zip> | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractCADLaTeX.zip> | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractNLMLaTeX.zip> | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractTFPLaTeX.zip> | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractTFQLaTeX.zip> | ||
#' * <https://www.tandf.co.uk/journals/authors/InteractTFSLaTeX.zip> | ||
#' | ||
#' @inheritParams rmarkdown::pdf_document | ||
#' @param reference_style should be set according to the specific Taylor & Francis | ||
#' journal. Possibles values: "APA" (American Psychological Association | ||
#' reference style), "CAD" (Chicago Author-Date reference style), "NLM" | ||
#' (National Library of Medicine reference style), "TFP" (Reference | ||
#' Style-P), "TFQ" (Reference Style-Q), and "TFS" (Reference Style-S). | ||
#' @param ... Additional arguments to [rmarkdown::pdf_document()] | ||
#' | ||
#' @examples \dontrun{ | ||
#' rmarkdown::draft("MyArticle.Rmd", template = "tf", package = "rticles") | ||
#' setwd("MyArticle") | ||
#' rmarkdown::render("MyArticle.Rmd") | ||
#' } | ||
#' @importFrom rmarkdown pandoc_variable_arg | ||
#' @export | ||
tf_article <- function(..., keep_tex = TRUE, citation_package = "natbib", | ||
reference_style = c("CAD", "APA", "NLM", "TFP", "TFQ", "TFS"), | ||
pandoc_args = NULL) { | ||
styles <- list( | ||
APA = list( | ||
bst = "apacite", | ||
cmd = c( | ||
"\\usepackage[natbibapa]{apacite}", | ||
"\\setlength\\bibhang{12pt}", | ||
"\\renewcommand\\bibliographytypesize{\\fontsize{10}{12}\\selectfont}" | ||
) | ||
), | ||
CAD = list( | ||
bst = "tfcad", | ||
cmd = c( | ||
"\\usepackage{natbib}", | ||
"\\bibpunct[, ]{(}{)}{;}{a}{}{,}" | ||
) | ||
), | ||
NLM = list( | ||
bst = "tfnlm", | ||
cmd = c( | ||
"\\usepackage[numbers,sort&compress]{natbib}", | ||
"\\makeatletter", | ||
"\\def\\NAT@def@citea{\\def\\@citea{\\NAT@separator}}", | ||
"\\makeatother", | ||
"\\bibpunct[, ]{[}{]}{,}{n}{,}{,}", | ||
"\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}" | ||
) | ||
), | ||
TFP = list( | ||
bst = "tfp", | ||
cmd = c( | ||
"\\usepackage[numbers,sort&compress,merge]{natbib}", | ||
"\\bibpunct[, ]{(}{)}{,}{n}{,}{,}", | ||
"\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}", | ||
"\\renewcommand\\citenumfont[1]{\\textit{#1}}", | ||
"\\renewcommand\\bibnumfmt[1]{(#1)}" | ||
) | ||
), | ||
TFQ = list( | ||
bst = "tfq", | ||
cmd = c( | ||
"\\usepackage[numbers,sort&compress]{natbib}", | ||
"\\bibpunct[, ]{[}{]}{,}{n}{,}{,}", | ||
"\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}" | ||
) | ||
), | ||
TFS = list( | ||
bst = "tfs", | ||
cmd = c( | ||
"\\usepackage[numbers,sort&compress]{natbib}", | ||
"\\bibpunct[, ]{[}{]}{,}{n}{,}{,}", | ||
"\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}" | ||
) | ||
) | ||
) | ||
reference_style <- match.arg(reference_style) | ||
if (! reference_style %in% names(styles)) | ||
stop( | ||
paste( | ||
"Invalid reference_style in Taylor and Francis article. Allowed values are:", | ||
paste(names(styles), collapse = ", ") | ||
) | ||
) | ||
sty <- styles[[reference_style]] | ||
pandoc_args <- c( | ||
pandoc_args, | ||
rmarkdown::pandoc_variable_arg("biblio-style", sty$bst), | ||
rmarkdown::pandoc_variable_arg( | ||
"biblio-commands", | ||
paste(sty$cmd, collapse = "\n") | ||
) | ||
) | ||
|
||
base <- pdf_document_format( | ||
"tf", | ||
keep_tex = keep_tex, | ||
citation_package = citation_package, | ||
pandoc_args = pandoc_args, | ||
... | ||
) | ||
pre_knit <- base$pre_knit | ||
|
||
# Alert the user about deprecation of the biblio_style field in the YAML header | ||
base$pre_knit <- function(input, metadata, ...) { | ||
if (is.function(pre_knit)) pre_knit(input, metadata, ...) | ||
if (!is.null(metadata$biblio_style)) | ||
warning("`tf_article()` now ignores the 'biblio_style' field in YAML header. ", | ||
" Use the 'reference_style' option of 'output:tf_article', instead.", | ||
call. = FALSE) | ||
} | ||
|
||
base | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.