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

Taylor & Francis Reference Style needs updating #556

Open
ehsanx opened this issue Dec 26, 2023 · 14 comments · May be fixed by #557
Open

Taylor & Francis Reference Style needs updating #556

ehsanx opened this issue Dec 26, 2023 · 14 comments · May be fixed by #557
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!

Comments

@ehsanx
Copy link

ehsanx commented Dec 26, 2023

Taylor & Francis Reference Style is different from the one provided by rticles::tf_article

The current rticles::tf_article provides the following in the tex file:
\usepackage{natbib}% Citation support using natbib.sty
\bibpunct[, ]{(}{)}{;}{a}{}{,}% Citation support using natbib.sty

However, as per https://files.taylorandfrancis.com/tf_S.pdf it should be simply
\usepackage[numbers]{natbib}


R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621), RStudio 2023.12.0.369

Locale:
LC_COLLATE=English_Canada.utf8 LC_CTYPE=English_Canada.utf8 LC_MONETARY=English_Canada.utf8
LC_NUMERIC=C LC_TIME=English_Canada.utf8

time zone: America/Vancouver
tzcode source: internal

Package version:
base64enc_0.1.3 bslib_0.5.1 cachem_1.0.8 cli_3.6.1 digest_0.6.31
ellipsis_0.3.2 evaluate_0.23 fastmap_1.1.1 fontawesome_0.5.2 fs_1.6.3
glue_1.6.2 graphics_4.3.0 grDevices_4.3.0 highr_0.10 htmltools_0.5.5
jquerylib_0.1.4 jsonlite_1.8.7 knitr_1.45 lifecycle_1.0.4 magrittr_2.0.3
memoise_2.0.1 methods_4.3.0 mime_0.12 R6_2.5.1 rappdirs_0.3.3
rlang_1.1.1 rmarkdown_2.25 rticles_0.25 sass_0.4.7 stats_4.3.0
stringi_1.7.12 stringr_1.5.0 tinytex_0.48 tools_4.3.0 utils_4.3.0
vctrs_0.6.4 xfun_0.39 yaml_2.3.7

By filing an issue to this repo, I promise that

  • [ x] I have fully read the issue guide at https://yihui.name/issue/.
  • [ x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rticles'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rticles').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [ x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Dec 27, 2023

Thanks for opening an issue.

It seems indeed there was an update in the templates we can find at : https://files.taylorandfrancis.com/InteractCADLaTeX.zip

% interactcadsample.tex
% v1.04 - May 2023

\documentclass[]{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

But the bibpunct line is still there.

I can do the update for the template, but still this line would be there.

For which journal https://files.taylorandfrancis.com/tf_S.pdf ? maybe they use another template ?

It seems this Zip template uses the Chicago style author date (https://files.taylorandfrancis.com/tf_ChicagoAD.pdf)

@cderv cderv added feature a feature request or enhancement help wanted ❤️ we'd love your help! labels Dec 27, 2023
cderv added a commit that referenced this issue Dec 27, 2023
@cderv
Copy link
Collaborator

cderv commented Dec 27, 2023

I have updated to latest file from bundle linked.

Please do share any other T&F template that may not be compatible with this one.

It was initially added in #218 by @dleutnant and may not cover all the possible Journals

@ehsanx
Copy link
Author

ehsanx commented Dec 31, 2023

For which journal https://files.taylorandfrancis.com/tf_S.pdf ? maybe they use another template ?

I received it from the "Journal of Applied Statistics". Thanks!

@cderv
Copy link
Collaborator

cderv commented Jan 3, 2024

So this one: https://www.tandfonline.com/journals/cjas20

From their instruction (https://www.tandfonline.com/action/authorSubmission?show=instructions&journalCode=cjas20) they have other template available at https://files.taylorandfrancis.com/InteractTFSLaTeX.zip

This templates does have

\usepackage[numbers,sort&compress]{natbib}% Citation support using natbib.sty
\bibpunct[, ]{[}{]}{,}{n}{,}{,}% Citation support using natbib.sty

and probably other differences like

\bibliographystyle{tfs}

This bst file does follow : http://www.tandf.co.uk/journals/authors/style/reference/tf_S.pdf

So probably those options can help... the templates needs to be adapted to pass those and it should be fine 🤔

Not sure we can do one template for all journals - an author would need to download the resources from the website probably and use them with the rticles template.

@cderv cderv linked a pull request Jan 3, 2024 that will close this issue
@cderv
Copy link
Collaborator

cderv commented Jan 3, 2024

Something does not seem to work ok with tfs.bst provided in the template... So it needs more work.

You have the PR linked if you want to try and help adapt

@rlaboiss
Copy link

rlaboiss commented Nov 18, 2024

The situation is more complex than described in the present issue. Taylor & Francis provides other templates besides the Chicago author-date (originally include in rticles) and the S template mentioned above. I found the templates listed below, along with the associated ZIP file, provided by T&F. I do not know if this list is exhaustive. The LaTeX sample files interact*sample.tex in these templates differ from each other. The ZIP tarballs contain different interact.cls files and, of course, the interact*sample.tex files vary as regards the argument of the \bibliographystyle command.

  • APA (InteractAPALaTeX.zip)
    • interact.cls v1.05
    • interactapasample.tex template provided
    • \bibliographystyle{apacite}
  • Chicago AD (InteractCADLaTeX.zip)
    • interact.cls v1.03
    • interactcadsample.tex template provided
    • \bibliographystyle{tfcad} (file tfcad.bst provided)
  • NLM (InteractNLMLaTeX.zip)
    • interact.cls v1.05
    • interactnlmsample.tex template provided
    • \bibliographystyle{tfnlm} (file tfnlm.bst provided)
  • P (InteractTFPLaTeX.zip)
    • interact.cls v1.01
    • interacttfpsample.tex template provided
    • \bibliographystyle{tfp} (file tfp.bst provided)
  • Q (InteractTFQLaTeX.zip)
    • interact.cls v1.05
    • interacttfqsample.tex template provided
    • \bibliographystyle{tfq} (file tfq.bst provided)
  • S (InteractTFSLaTeX.zip)
    • interact.cls v1.05
    • interacttfssample.tex template provided
    • \bibliographystyle{tfs} (file tfs.bst provided)

I am aware of issue #321, where the adaptation to the APA style has been discussed. The ideal solution would be to generalize the approach in PR #557. However, besides the appropriate argument for the \bibliograpystyle command, the interact.cls should be selected among the version 1.01, 1.03, and 1.05 (see above) and the appropriate interact*sample.tex should be selected according to the desired reference style specified by the user.

I could try to propose a PR for this, but I am afraid I konw very little from the internals of rticles.

@cderv
Copy link
Collaborator

cderv commented Nov 18, 2024

Thanks a lot for all this listing. It seems indeed more complex 🤔

I could try to propose a PR for this, but I am afraid I konw very little from the internals of rticles.

Internal is not that hard, and I can help with that or adapt from where you have something working. We don't have a few example though where one article function handle several template... Usually it is one function = one template. So the decision will be about: is this possible to make a single template configurable enough.

Example for the latter is

  • oup_article() was a format we needed to handle an upgrade with totally differente template. So it shows what we've done.
  • Some function have a journal argument to conditionally change some stuff for the template like ims_article, joss_article, oup_article, ...

If you spend some time looking at complex journal function we have, it would be a good example to see what is done usually.

However, if you have a design in mind, and would know what needs to differ between those templates, I can guide during the PR. Help very welcome on this TBH !

Some hints based on your comments

The ZIP tarballs contain different interact.cls files and, of course, the interact*sample.tex files vary as regards the argument of the \bibliographystyle command.

It seems we need to store all class files in the rticles package, and somehow rename / move it when installing. This is not ideal in current design as usually we have a folder we move to the project without change... So either we have different template with each there class file, or we make an exception with a new design to "install" the right version depending of the template. Or use the right version from the .tex file. Unless we named same with there version number, but this would modify the template .tex file I think

For the bibliostyle, this is definitly something that is configurable using R argument, and then pass the variable for the template. In this function for example, we build arguments to pass to the template

rticles/R/joss_article.R

Lines 20 to 40 in 1aee991

joss_article <- function(journal = "JOSS",
keep_md = TRUE,
latex_engine = "xelatex",
pandoc_args = NULL,
...) {
rmarkdown::pandoc_available("2.2", TRUE)
args <- list(
logo_path = find_resource("joss", paste0(journal, "-logo.png")),
journal_name = ifelse(journal == "JOSS", "Journal of Open Source Software", "Journal of Open Source Education"),
graphics = TRUE
)
pdf_document_format(
"joss",
latex_engine = latex_engine,
citation_package = "default",
keep_md = keep_md,
pandoc_args = c(pandoc_args, list_to_pandoc_variable_args(args)),
...)
}

So to me this is the hard part...

the interact.cls should be select among the version 1.01, 1.03, and 1.05 (see above)

Is there a reason they don't use the same ? Is that because template are not up to date and they should use it ? Or should we really maintain version difference ?

Thanks a lot

@rlaboiss
Copy link

rlaboiss commented Nov 18, 2024

Thank you for your thorough comments. I may try to propose a PR along the lines you suggested.

So to me this is the hard part...

the interact.cls should be selected among the version 1.01, 1.03, and 1.05 (see above)

Is there a reason they don't use the same ? Is that because template are not up to date and they should use it ? Or should we really maintain version difference ?

I have no idea about the answers to these questions. Perhaps, everything would be fine with the latest version of interact.cls (1.05).

A very simple way to cope with the problem would be to create separate functions (and separate template directories) for each reference style, namelytf_apa, tf_cad, tf_nlm, tf_tfp, tf_tfq, and tf_tfs, with tf_article as an alias to tf_cad, for backward compatibility. I admit that this solution is pretty cumbersome, since there will be many duplicated files everywhere.

Another solution would be to allow the specification of which files under rmarkdown/templates/tf/skeleton/ should be copied, according to the user's choice. However, it seems that this is under the responsibility of rmarkdown::draft and is beyond the scope of rticles.

A feasible solution would be to add all versions of interact.cls, eventually renaming them to interact-v1.01.cls, interact-v1.03.cls, and interact-v1.05.cls and ship an interact.cls file that uses some TeX logic to \include the appropriate .cls file. Also, all the tf_*.bst would be included in the skeleton directory, with some Pandoc conditional logic around the \bibliographystyle command. This solution would have two drawbacks: first, the template.tex would be complex, including lots of conditionals for the different reference styles, and, second, the user will get a lot of useless files installed along their draft.

@cderv
Copy link
Collaborator

cderv commented Nov 18, 2024

A very simple way to cope with the problem would be to create separate functions (and separate template directories) for each reference style, namelytf_apa, tf_cad, tf_nlm, tf_tfp, tf_tfq, and tf_tfs, with tf_article as an alias to tf_cad, for backward compatibility. I admit that this solution is pretty cumbersome, since there will be many duplicated files everywhere.

Definitely, but we have a duplication problem for sure. CRAN package size are limited so I need to keep the size of the package under contraints too.

Another solution would be to allow the specification of which files under rmarkdown/templates/tf/skeleton/ should be copied, according to the user's choice. However, it seems that this is under the responsibility of rmarkdown::draft and is beyond the scope of rticles.

Yes exactly. We are tied by draft() design here.

A feasible solution would be to add all versions of interact.cls, eventually renaming them to interact-v1.01.cls, interact-v1.03.cls, and interact-v1.05.cls and ship an interact.cls file that uses some TeX logic to \include the appropriate .cls file.

This would be possible, but the .tex file produced needs to be compatible with the expectation of the journal. I wonder if they would accept modified .tex content like this to comply with our problems ? 🤔

Maybe there is a middle option where could have one template folder with all resource except the class file, and the correct cls file would be copied into directory at render time - right before rendering with pandoc and dependending on the article function used ?

Usually we do copy everything at draft building but maybe we can make an exception here, and copy only when used so .cls and .bst as we don't know beforehand which one is needed.

I could also see if there is an adjustement without breaking change I could make in rmarkdown::draft() that would help with this case... I need to check that RStudio IDE is indeed using draft() too so that those template can work in the menu to create new template.

@rlaboiss
Copy link

I could also see if there is an adjustement without breaking change I could make in rmarkdown::draft() that would help with this case... I need to check that RStudio IDE is indeed using draft() too so that those template can work in the menu to create new template.

If you can change rmarkdown::draft(), it will be great. It should be okay, in terms of backward compatibility, if you added an argument for specifying the list of extra files to be installed.

@rlaboiss
Copy link

I could also see if there is an adjustement without breaking change I could make in rmarkdown::draft() that would help with this case... I need to check that RStudio IDE is indeed using draft() too so that those template can work in the menu to create new template.

If you can change rmarkdown::draft(), it will be great. It should be okay, in terms of backward compatibility, if you added an argument for specifying the list of extra files to be installed.

Any news about this?

I need to prepare a manuscript for publication in a Taylor & Francis journal, which uses the InteractAPA style. Is there a simple way to change the template used by rmarkdown::render?

@rlaboiss
Copy link

I need to prepare a manuscript for publication in a Taylor & Francis journal, which uses the InteractAPA style. Is there a simple way to change the template used by rmarkdown::render?

Waiting for the fix for the issue in question, I got around my problem of using apacite with tf_article. I describe my solution below, in case someone stumbles over the same problem.

  1. Copy the template rticles/rmarkdown/templates/tf/resources/template.tex into the same directory as the source .Rmd file and apply the following patch to it:
--- template-tf-article.tex	2024-11-26 08:14:45.751008046 +0100
+++ template.tex	2024-11-26 07:49:53.000000000 +0100
@@ -7,9 +7,9 @@
 \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
+\usepackage[natbibapa]{apacite}% Citation support using apacite.sty. Commands using natbib.sty MUST be deactivated first!
+\setlength\bibhang{12pt}% To set the indentation in the list of references using apacite.sty. Commands using natbib.sty MUST be deactivated first!
+\renewcommand\bibliographytypesize{\fontsize{10}{12}\selectfont}% To set the list of references in 10 point font using apacite.sty. Commands using natbib.sty MUST be deactivated first!
 
 \theoremstyle{plain}% Theorem-like structures provided by amsthm.sty
 \newtheorem{theorem}{Theorem}[section]
  1. In the YAML header of the .Rmd file, use:
biblio-style: apacite
output: function(){t<-rticles::tf_article();t$pandoc$args[4]<-"template.tex";t}
  1. Replace the interact.cls file installed by rmarkdown::draft by the one provided in InteractAPALaTeX.zip.

I admit that it is hacky, but it works for me.™

@cderv
Copy link
Collaborator

cderv commented Nov 26, 2024

Any news about this?

Quarto 1.6 is now release (yesterday) so I am getting back to this package for an update. I'll look at draft() but I admit last time I did try to improve it for oup_article() I did not found an easy way.

i'll revisit. Though glad you found a solution in the meantime.

output: function(){t<-rticles::tf_article();t$pandoc$args[4]<-"template.tex";t}

I would have expected that the template could be replaced directly

output:
  rticles::tf_article:
    template: patch-template.tex

Is this not working ?

@rlaboiss
Copy link

I would have expected that the template could be replaced directly

output:
  rticles::tf_article:
    template: patch-template.tex

Is this not working ?

Yes, it does. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants