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

Biobliography not formatted correctly in rticles::elsevier_article #545

Closed
pepijn-devries opened this issue Oct 12, 2023 · 18 comments
Closed

Comments

@pepijn-devries
Copy link

Thanks for your work on rticles. It really helped me to streamline my publication process.

When using rticles::elsevier_article I noticed that the bibliography was formatted incorrectly (e.g., first names showing first instead of last names). For me adding biblio-style: elsarticle-harv to the yaml header fixed the issue. Maybe this can be included in the default template, or it can be noted in the documentation?

This is my session info:

sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=Dutch_Netherlands.1252  LC_CTYPE=Dutch_Netherlands.1252   
#> [3] LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C                      
#> [5] LC_TIME=Dutch_Netherlands.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.31   withr_2.5.0     lifecycle_1.0.3 reprex_2.0.2   
#>  [5] evaluate_0.21   rlang_1.1.0     cli_3.4.1       rstudioapi_0.13
#>  [9] fs_1.6.2        rmarkdown_2.22  tools_4.1.1     glue_1.6.2     
#> [13] xfun_0.37       yaml_2.3.7      fastmap_1.1.0   compiler_4.1.1 
#> [17] htmltools_0.5.4 knitr_1.42

Created on 2023-10-12 with reprex v2.0.2

@cboettig @robjhyndman

@cderv
Copy link
Collaborator

cderv commented Oct 12, 2023

It seems the template was done using plainnat by default

$if(natbib)$
\usepackage[$natbiboptions$]{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$

The LaTeX package guideline (https://www.elsevier.com/authors/policies-and-guidelines/documents/elsdoc-1.pdf)

Three bibliographic style files (*.bst) are provided — elsarticle-num.bst,
elsarticle-num-names.bst and elsarticle-harv.bst

I am fine by using one of this as the default if that is better

@pepijn-devries
Copy link
Author

Or perhaps include all options in the template and comment out all but one. Than it is visible to the user what the options are.

@cderv
Copy link
Collaborator

cderv commented Oct 12, 2023

In fact re-reading the guidelines, I am seeing this about class option

authoryear
author-year citation style of natbib.sty. If you want to add
extra options of natbib.sty, you may use the options as comma
delimited strings as arguments to \biboptions command.

And we use it in the template in classoptions. Is it set for you ?

Not sure how it effect and which bibliostyle should be set with it 🤔

@pepijn-devries
Copy link
Author

pepijn-devries commented Oct 12, 2023

This is what my yaml-header looks like at the moment. I do have the authoryear option set at the classoption. But without the biblio-style setting defined the bibliography is not formatted correctly. I've added it myself to the default template.

title: "TODO"
author:
  - name: TODO
    email: TODO
    affiliation: TODO
    correspondingauthor: true
address:
  - code: WUR
    organization: TODO
    addressline: TODO
    city: TODO
    postcode: TODO
    country: The Netherlands
abstract: |
  TODO
keywords: 
  - TODO
  - TODO
journal: "TODO"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
bibliography: library.bib
biblio-style: elsarticle-harv
linenumbers: true
numbersections: true
# Use a CSL with `citation_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
output: 
  rticles::elsevier_article:
    keep_tex: true
    citation_package: natbib

@cderv cderv closed this as completed in 8dd188a Oct 12, 2023
@cderv
Copy link
Collaborator

cderv commented Oct 12, 2023

I did the update in the skeleton following this advice. Thank you !

@eugenividal
Copy link

eugenividal commented Dec 25, 2023

Hi @cderv. Great package! I have the same problem reported here: The Reference list shows first names instead of last names. Adding biblio-style: elsarticle-harv to the yaml header does not work for me. If I add it I get:
Screenshot from 2023-12-25 16-19-55

@pepijn-devries
Copy link
Author

Hi @eugenividal,

For me the solution above did work. Maybe you could add the complete yaml header that you are using. Otherwise it is impossible to reproduce or solve your problem.

Cheers,

Pepijn

@eugenividal
Copy link

eugenividal commented Dec 28, 2023

Hi @pepijn-devries, thanks for your quick reply. My complete yaml header is below. Now, if I use biblio-style: elsarticle-harv, I get no reference list at all; otherwise, I get the reference list but with first names showing first instead of last names. Should I add a file or something in my main folder to support this biblio-style: elsarticle-harv?

Screenshot from 2023-12-28 08-55-18

@pepijn-devries
Copy link
Author

pepijn-devries commented Dec 28, 2023

Hi @eugenividal,

I've installed the latest version of rticles from CRAN, and created an RMarkdown document in RStudio from the rticles template. I've used the same settings in my yaml header as you are using above. You don't need to place any files (other than the bibliography) anywhere. All required files are included in the package. For me the pdf is generated without any issues. Which latex engine are you using?

Cheers,

Pepijn

@eugenividal
Copy link

Hi @pepijn-devries, thanks for your answer. I've installed the latest version of rticles too but I still get an error (below). I've no idea which latex engine I am using. I guess the one markdown uses by default. Not sure how can I check that.

Screenshot from 2023-12-28 17-01-17

@cderv
Copy link
Collaborator

cderv commented Dec 29, 2023

elsarticle-harv.bst seems not found. Though it should be availabel through the CTAN package
https://ctan.org/tex-archive/macros/latex/contrib/elsarticle

So check that you have this package installed, and latest version.

If you are using TinyTeX, it should be installed automatically when missing. You can also install and update manually

@pepijn-devries
Copy link
Author

pepijn-devries commented Dec 29, 2023

@cderv Good point. That is probably it. I'm also working with TinyTex as it generally plays nicely with RMarkdown and knitr.

@eugenividal
Copy link

eugenividal commented Dec 30, 2023

Thanks @cderv. It is working properly now! What do you mean by checking that the package is installed? I just had to save the elsarticle-harv.bst file in the main folder and knit the Rmd with the biblio-style: elsarticle-harv uncommented.

@cderv
Copy link
Collaborator

cderv commented Jan 3, 2024

What do you mean by checking that the package is installed?

elsarticle-harv.bst is availabel through a CTAN package https://ctan.org/tex-archive/macros/latex/contrib/elsarticle, so if that package is installed, files provided by this package should have been found correctly.

Placing the file locally works too though.

@eugenividal
Copy link

Hi @cderv. Thanks for the clarification. This is what I thought. I just do not know how to install the CTAN package. Is this an R package? Can I install it using my ubuntu terminal? Thanks!

@cderv
Copy link
Collaborator

cderv commented Jan 8, 2024

CTAN is https://ctan.org/ - this is the package repository for LaTeX package. Like CRAN for R or CPAN for perl.

Installing a package for LaTeX can be done using TeX Live tlmgr install command. Or tinytex::tlmgr_install() from R is you use TinyTeX and tinytex R package.

Though as I said, it should be done automatically when a missing package is detected. So if it does not do it for you, it means either you don't use TeX Live, or something else prevent installation.

Anyhow, if you start managing TeX Live yourself, or at least do some stuff with LaTeX distribution, you should understand how it works.

@eugenividal
Copy link

eugenividal commented Jan 8, 2024

Thanks for the information, @cderv. I've just run tinytex::install_tinytex() in my Rstudio console and this time the file elsarticle-harv.bst was not required to work properly.

Copy link

github-actions bot commented Jul 8, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants