-
Notifications
You must be signed in to change notification settings - Fork 522
Add support to all bibliography styles required by Taylor & Francis journals #581
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
Merged
Merged
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 8ecb69c
Cope with absent "biblio-style" field in the YAML header
rlaboiss a1774b4
Use pandoc substitution variable bst-name instead of biblio-style
rlaboiss eab22c5
Adapt article sample for all T&F reference styles
rlaboiss acec4e6
Replace tilde ("~") by " "
rlaboiss 11dc4eb
Add the appropriate References section
rlaboiss 97dedba
Drop obsolete file name at the top
rlaboiss 6aa60cf
Ensure that CAD reference style is done with author-date natbib scheme
rlaboiss da8f5e2
Replace tilde with non-breaking space
rlaboiss 6715c81
Reword caveat
rlaboiss dfca827
Do bibliography commands logic in R instead of doing in TeX
rlaboiss 0099208
Put the tf_article function into a separate file (R/tf_article.R)
rlaboiss 9356136
Specify candidate values for the biblio_style argument
rlaboiss 5501b40
Use character vectors and paste() in order to avoid fragile code form…
rlaboiss 0b368f1
Add myself as contributor
rlaboiss bbf9123
Deprecate the biblio_style option and rename the reference_style option
rlaboiss b23d6bd
Indicate the origin sources
rlaboiss db2d5cb
Fix example
rlaboiss 62f6467
Propagate fix into documentation file
rlaboiss acee0db
Provide a working example in the documentation
rlaboiss 49b92e1
Propagate fix into documentation file
rlaboiss 74e81c5
Fix word "below" ⇒ "above"
rlaboiss 4af845f
Appropriately escape backslashes in strings
rlaboiss a0ac4c4
Reduce the amount of entries in the BibTeX file to the minimum necessary
rlaboiss 02da0fd
Drop leading empty line
rlaboiss e0b8e90
Use Unicode escaping in my family name
rlaboiss d867df9
test all new TF article reference style
cderv 2ab77b5
Merge branch 'main' into taylor-and-francis
cderv 6c5ef4a
Trying back using accented character in DESCRIPTION
cderv 17170b0
Bump version
cderv f6937cc
Merge branch 'main' into taylor-and-francis
cderv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.