-
Notifications
You must be signed in to change notification settings - Fork 525
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
Conversation
…ournals * R/article.R: Check whether the biblio-style field in the YAML header contains one of the allowed values * inst/rmarkdown/templates/tf/skeleton/interact.cls: Update to version v1.05 * inst/rmarkdown/templates/tf/resources/template.tex: Choose the bibliography-related code according to biblio-style * inst/rmarkdown/templates/tf/skeleton/tf{nlm,p,q,s}.bst: Add lacking bibliography style files from T&F * man/article.Rd: Document the changes
* R/article.R: Add option biblio_style (with default value "CAD"), which is used to set the bst-name pandoc substitution variable * inst/rmarkdown/templates/tf/resources/template.tex: - Use variable bst-name - This simplifies the \bibliographystyle command * man/article.Rd: Update documentation for tf_article
The “References cited in the text” sections of the Taylor & Francis samples (interactapasample.tex, interactcadsample.tex, interactnlmsample.tex, interacttfpsample.tex, interacttfqsample.tex, and interacttfssample.tex) are merged into the skeleton.Rmd, with each reference style being treated in a separate subsection. Also, the entries in the BibTeX files interactapasample.bib, interactcadsample.bib, interactnlmsample.bib, interacttfpsample.bib, interacttfqsample.bib, and interacttfssample.bib are merged into interactsample.bib.
The convoluted logic using \ifboolexpr and \ifstrequal in the preamble of template.tex is done now done in function tf_article(). A new pandoc variable ("biblio-commands") is now used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this PR. Really good to see how the template can be improved.
For the biblio-style
logic, you could have also be processing depending on the value of the biblio-style
Let's take this example
output: tf_article
biblio_style: tfcad.bst
This following usual syntax.
As a pre_processor
in the format, you could check for biblio-style
value, and check that xfun::sans_ext(metadata$biblio-style)
a known value. If not you would error, if this is you would then define the appropriate pandoc_variable_arg("biblio-commands")
associated with this style.
This is an idea to keep the same YAML metadata as other format, while adding a specific processing to it.
I am using pre_processor
here, because this function returns new args to be used with Pandoc.
guess that, in case my PR get merged, my name will appear in the DESCRIPTION file. Please, tell me which role should I indicated for myself.
Please add yourself in DESCRIPTION as other contributor.
Should I add my name and affiliation in the YAML header of inst/rmarkdown/templates/tf/skeleton/skeleton.Rmd?
The skeleton is an example so no need to add you to it, unless you want to be the example.
There is only an annoying point: all tf*.bst are installed by
I don't think that is a big issue. A user will have to remove the undesired one. Otherwise, we need to think about this dynamically and only copy at render time the right file from resources if not already there. It could be tricky but this is the only way without modifying general draft logic.
Otherwise maybe I need to do a rticles::create_article()
that would wrap the default draft, but do some postprocessing too depending on some specific rules 🤷
I also triggered the test and they are failing. This is because documentation needs to be updated in Roxygen command. By creating a new file for this function it will solve it I thhink.
Thanks again.
I need a clarification here. Are you proposing that we should only have the biblio_style metadata variable (containing the name of the .bst file), like this:
instead of the scheme that I implemented, like this:
or are you proposing to keep both possibilities? |
Yes I am suggesting we could use the existing It could be Do you think this is not great user experience ? |
Oh, this would change completely my design! The existing The I did this on purpose, such that the user does not need to know which specific BTW, this is the reason why I used Now, if I follow your suggestion, I would have to set If you accept that my design is maintained, I could add a note in the documentation of We might also change the name of the argument from
What do you think? |
This commit is intended to eliminate an ambiguity linked to the use of biblio_style as the name of the tf_article function option. In fact, biblio_style is traditionally used in the rticles package to indicate the name of the .bst file that will be used as an argument to the \bibliographystyle command in the LaTeX template. The new version of tf_article accepts an option that determines the Taylor & Francis reference style to be used. Until now, the name biblio_style was used as the name of this option. In this commit, this name is changed to reference_style. This not only aligns with the terminology used by Francis & Taylor (“Reference Style”), but also avoids any confusion on the part of the user. The tf_article function has also been modified to include a pre_knit function, in which the presence of the biblio_style in the YAML header is checked. If present, a warning message is issued concerning the depreciation of the biblio_style field.
In order to make things more concrete, I went ahead and pushed commit bbf9123 containing changes along the lines above. Here is the commit's log message: Deprecate the biblio_style option and rename the reference_style option This commit is intended to eliminate an ambiguity linked to the use of biblio_style as the name of the tf_article function option. In fact, biblio_style is traditionally used in the rticles package to indicate the name of the .bst file that will be used as an argument to the \bibliographystyle command in the LaTeX template. The new version of tf_article accepts an option that determines the Taylor & Francis reference style to be used. Until now, the name biblio_style was used as the name of this option. In this commit, this name is changed to reference_style. This not only aligns with the terminology used by Francis & Taylor (“Reference Style”), but also avoids any confusion on the part of the user. The tf_article function has also been modified to include a pre_knit function, in which the presence of the biblio_style in the YAML header is checked. If present, a warning message is issued concerning the depreciation of the biblio_style field. |
Yes this is possible. In post processor, you check the This is quite similar to your current design except:
The only drawback I see for your current design is that no custom I don't think that is common, but hiding behind |
Yes, I think that this situation (need to use another
Such a setup is almost guaranteed to produce broken results. At any rate, I think that the PR is now ready for merging. I did extensive tests and the |
To be clear on my thinking, this would not happen as you wouldn't need It is either biblio_style: tfcad
output: rticles::tf_article and this would trigger CAD style command addition. No reference_style needed Or output:
rticles::tf_article:
reference_style: CAD without needing This biblio_style: tfcad
output:
rticles::tf_article:
reference_style: NLM would be handled by
This is awesome ! Thanks a lot for the work on this - greatly appreciated! |
How to contribute a new output format ?
To contribute a new article template to this package, please make sure you have done the following things (note that
journalname_article
below is only an example name):This project uses a Contributor Licence Agreement (CLA) that you'll be asked to sign when opening a PR. This is required for a significant pull request (it is fine not to sign it if a PR is only intended to fix a few typos). Unless you have done it in any other RStudio / Posit projects before, sign the individual or corporate contributor agreement as appropriate. You can send the signed copy to [email protected].
Add the
journalname_article()
function toR/article.R
if the output format is simple enough, otherwise create a separateR/journalname_article.R
.Document your function using roxygen2. Markdown syntax is supported. Refer to https://roxygen2.r-lib.org/articles/rd-formatting.html for formatting references.
Add the Pandoc LaTeX template
inst/rmarkdown/templates/journalname/resources/template.tex
.Add a skeleton article
inst/rmarkdown/templates/journalname/skeleton/skeleton.Rmd
.Add a description of the template
inst/rmarkdown/templates/journalname/template.yaml
.Please include the document class file (
*.cls
) if needed, but please do not include standard LaTeX packages (*.sty
) that can be downloaded from CTAN. If you are using TinyTeX or TeX Live, you can verify if a package is available on CTAN viatinytex::parse_packages(files = "FILENAME"")
(e.g., whenFILENAME
isplain.bst
, it should return"bibtex"
, which means this file is from a standard CTAN package). Please keep the number of new files absolutely minimal (e.g., do not include PDF output files), and also make examples minimal (e.g., if you need a.bib
example, try to only leave one or two bibliography entries in it, and don't include too many items in it without using all of them).Update Rd and namespace (could be done by
devtools::document()
).Update NEWS.
Update README with a link to the newly supported journal. Please add your Github username and the full name of the journal (follow other examples in the list).
Add a test to
tests/testit/test-formats.R
by adding a linetest_format("journalname")
. We try to keep them in alphabetical order.Add your name to the list of authors
Authors@R
in DESCRIPTION. You don't need to bump the package version in DESCRIPTION.Lastly, please try your best to do only one thing per pull request (e.g., if you want to add two output formats, do them in two separate pull requests), and refrain from making cosmetic changes in the code base: https://yihui.name/en/2018/02/bite-sized-pull-requests/
Thank you!