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 11 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
63 changes: 61 additions & 2 deletions R/article.R
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,69 @@ springer_article <- function(..., keep_tex = TRUE, citation_package = "natbib",
#' \samp{https://www.tandf.co.uk/journals/authors/InteractCADLaTeX.zip}.
#' @export
#' @rdname article
tf_article <- function(..., keep_tex = TRUE, citation_package = "natbib") {
tf_article <- function(..., keep_tex = TRUE, citation_package = "natbib",
biblio_style = "CAD", pandoc_args = NULL) {
styles <- list(
APA = list(
bst = "apacite",
cmd = "\\usepackage[natbibapa]{apacite}
\\setlength\\bibhang{12pt}
\\renewcommand\\bibliographytypesize{\\fontsize{10}{12}\\selectfont}"
),
CAD = list(
bst = "tfcad",
cmd = "\\usepackage{natbib}
\\bibpunct[, ]{(}{)}{;}{a}{}{,}"
),
NLM = list(
bst = "tfnlm",
cmd = "\\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 = "\\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 = "\\usepackage[numbers,sort&compress]{natbib}
\\bibpunct[, ]{[}{]}{,}{n}{,}{,}
\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}"
),
TFS = list(
bst = "tfs",
cmd = "\\usepackage[numbers,sort&compress]{natbib}
\\bibpunct[, ]{[}{]}{,}{n}{,}{,}
\\renewcommand\\bibfont{\\fontsize{10}{12}\\selectfont}"
)
)
if (! biblio_style %in% names(styles))
stop(
paste(
"Invalid biblio_style in Taylor and Francis article. Allowed values are:",
paste(names(styles), collapse = ", ")
)
)
sty <- styles[[biblio_style]]
pandoc_args <- c(
pandoc_args,
rmarkdown::pandoc_variable_arg("bst-name", sty$bst),
rmarkdown::pandoc_variable_arg("biblio-commands", sty$cmd)
)
pdf_document_format(
"tf",
keep_tex = keep_tex, citation_package = citation_package, ...
keep_tex = keep_tex,
citation_package = citation_package,
pandoc_args = pandoc_args,
...
)
}

Expand Down
9 changes: 2 additions & 7 deletions inst/rmarkdown/templates/tf/resources/template.tex
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
% interactcadsample.tex
% v1.04 - May 2023

\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$

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

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

Expand Down
Loading
Loading