Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to all bibliography styles required by Taylor & Francis journals #581

Merged
merged 31 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
961e7fa
Add support to all bibliography styles required by Taylor & Francis j…
rlaboiss Nov 30, 2024
8ecb69c
Cope with absent "biblio-style" field in the YAML header
rlaboiss Dec 1, 2024
a1774b4
Use pandoc substitution variable bst-name instead of biblio-style
rlaboiss Dec 1, 2024
eab22c5
Adapt article sample for all T&F reference styles
rlaboiss Dec 2, 2024
acec4e6
Replace tilde ("~") by " "
rlaboiss Dec 2, 2024
11dc4eb
Add the appropriate References section
rlaboiss Dec 2, 2024
97dedba
Drop obsolete file name at the top
rlaboiss Dec 2, 2024
6aa60cf
Ensure that CAD reference style is done with author-date natbib scheme
rlaboiss Dec 2, 2024
da8f5e2
Replace tilde with non-breaking space
rlaboiss Dec 2, 2024
6715c81
Reword caveat
rlaboiss Dec 2, 2024
dfca827
Do bibliography commands logic in R instead of doing in TeX
rlaboiss Dec 3, 2024
0099208
Put the tf_article function into a separate file (R/tf_article.R)
rlaboiss Dec 12, 2024
9356136
Specify candidate values for the biblio_style argument
rlaboiss Dec 12, 2024
5501b40
Use character vectors and paste() in order to avoid fragile code form…
rlaboiss Dec 12, 2024
0b368f1
Add myself as contributor
rlaboiss Dec 13, 2024
bbf9123
Deprecate the biblio_style option and rename the reference_style option
rlaboiss Dec 13, 2024
b23d6bd
Indicate the origin sources
rlaboiss Dec 13, 2024
db2d5cb
Fix example
rlaboiss Dec 13, 2024
62f6467
Propagate fix into documentation file
rlaboiss Dec 14, 2024
acee0db
Provide a working example in the documentation
rlaboiss Dec 14, 2024
49b92e1
Propagate fix into documentation file
rlaboiss Dec 14, 2024
74e81c5
Fix word "below" ⇒ "above"
rlaboiss Dec 14, 2024
4af845f
Appropriately escape backslashes in strings
rlaboiss Dec 14, 2024
a0ac4c4
Reduce the amount of entries in the BibTeX file to the minimum necessary
rlaboiss Dec 14, 2024
02da0fd
Drop leading empty line
rlaboiss Dec 14, 2024
e0b8e90
Use Unicode escaping in my family name
rlaboiss Dec 14, 2024
d867df9
test all new TF article reference style
cderv Dec 16, 2024
2ab77b5
Merge branch 'main' into taylor-and-francis
cderv Dec 16, 2024
6c5ef4a
Trying back using accented character in DESCRIPTION
cderv Dec 16, 2024
17170b0
Bump version
cderv Dec 16, 2024
f6937cc
Merge branch 'main' into taylor-and-francis
cderv Dec 16, 2024
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
6 changes: 4 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.9
Version: 0.27.10
Authors@R: c(
person("JJ", "Allaire", , "[email protected]", role = "aut"),
person("Yihui", "Xie", , "[email protected]", role = "aut",
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 0 additions & 11 deletions R/article.R
cderv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,6 @@ springer_article <- function(..., keep_tex = TRUE, citation_package = "natbib",
format
}

#' @section `tf_article`: Format for creating submissions to a Taylor & Francis journal. Adapted from
#' \samp{https://www.tandf.co.uk/journals/authors/InteractCADLaTeX.zip}.
#' @export
#' @rdname article
tf_article <- function(..., keep_tex = TRUE, citation_package = "natbib") {
pdf_document_format(
"tf",
keep_tex = keep_tex, citation_package = citation_package, ...
)
}

#' @section \code{trb_article}: Format for creating submissions to the Transportation
#' Research Board Annual Meeting. Adapted from
#' \samp{https://www.overleaf.com/latex/templates/transportation-research-board-trb-latex-template/jkfndnnkkksw},
Expand Down
121 changes: 121 additions & 0 deletions R/tf_article.R
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
}
17 changes: 11 additions & 6 deletions inst/rmarkdown/templates/tf/resources/template.tex
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
% interactcadsample.tex
% v1.04 - May 2023
% Template for Taylor & Francis journals
%
% Based on the original files distributed by T&F:
% * interactapasample.tex: v1.05 - August 2017
% * interactcadsample.tex: v1.04 - May 2023
% * interactnlmsample.tex: v1.05 - August 2017
% * interacttfpsample.tex: v1.01 - June 2016
% * interacttfqsample.tex: v1.05 - August 2017
% * interacttfssample.tex: v1.05 - August 2017
rlaboiss marked this conversation as resolved.
Show resolved Hide resolved

\documentclass[$for(classoption)$$classoption$$sep$,$endfor$]{interact}

\usepackage{epstopdf}% To incorporate .eps illustrations using PDFLaTeX, etc.
\usepackage{subfigure}% Support for small, `sub' figures and tables
%\usepackage[nolists,tablesfirst]{endfloat}% To `separate' figures and tables from text if required

\usepackage{natbib}% Citation support using natbib.sty
\bibpunct[, ]{(}{)}{;}{a}{}{,}% Citation support using natbib.sty
\renewcommand\bibfont{\fontsize{10}{12}\selectfont}% Bibliography support using natbib.sty
$biblio-commands$
cderv marked this conversation as resolved.
Show resolved Hide resolved

\theoremstyle{plain}% Theorem-like structures provided by amsthm.sty
\newtheorem{theorem}{Theorem}[section]
Expand Down Expand Up @@ -202,7 +207,7 @@
$body$

$if(bibliography)$
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$tfcad$endif$}
\bibliographystyle{$biblio-style$}
\bibliography{$bibliography$}
$endif$

Expand Down
Loading