rstudio / rticles

LaTeX Journal Article Templates for R Markdown
https://pkgs.rstudio.com/rticles/
1.47k stars 520 forks source link

Taylor & Francis Reference Style needs updating #556

Open ehsanx opened 11 months ago

ehsanx commented 11 months ago

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

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

cderv commented 11 months ago

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 commented 11 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 4 days ago

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.

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 commented 4 days ago

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

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 https://github.com/rstudio/rticles/blob/1aee9911a3c205e2434f6fba0259396526ea59b4/R/joss_article.R#L20-L40

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 commented 3 days ago

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 commented 3 days ago

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 commented 3 days ago

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.