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

Improving BibTeX citation entries #2361

Closed
fkohrt opened this issue Sep 14, 2024 · 5 comments
Closed

Improving BibTeX citation entries #2361

fkohrt opened this issue Sep 14, 2024 · 5 comments

Comments

@fkohrt
Copy link
Contributor

fkohrt commented Sep 14, 2024

withr::with_options(
  list(warnPartialMatchArgs = TRUE,
       warnPartialMatchDollar = TRUE,
       warnPartialMatchAttr = TRUE,
       warn = 1,
       lifecycle_verbosity = "warning"
  ), {
    toBibtex(citation("knitr"))
  })

...gives the following:

Warning in meta$Date : partial match of 'Date' to 'Date/Publication'
Calls: toBibtex ... readCitationFile -> eval -> eval -> sub -> is.factor
@Manual{,
  title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
  author = {Yihui Xie},
  year = {2024},
  note = {R package version 1.48},
  url = {https://yihui.org/knitr/},
}

@Book{,
  title = {Dynamic Documents with {R} and knitr},
  author = {Yihui Xie},
  publisher = {Chapman and Hall/CRC},
  address = {Boca Raton, Florida},
  year = {2015},
  edition = {2nd},
  note = {ISBN 978-1498716963},
  url = {https://yihui.org/knitr/},
}

@InCollection{,
  booktitle = {Implementing Reproducible Computational Research},
  editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},
  title = {knitr: A Comprehensive Tool for Reproducible Research in {R}},
  author = {Yihui Xie},
  publisher = {Chapman and Hall/CRC},
  year = {2014},
  note = {ISBN 978-1466561595},
}
  1. There's a warning about a partial match Not present anymore in the latest development version.
  2. R is not surrounded by curly braces in the first entry, making it lowercase in certain citation styles.
xfun::session_info('knitr')
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS

Locale:
  LC_CTYPE=C.UTF-8       LC_NUMERIC=C          
  LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
  LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
  LC_PAPER=C.UTF-8       LC_NAME=C             
  LC_ADDRESS=C           LC_TELEPHONE=C        
  LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

Package version:
  evaluate_1.0.0  graphics_4.4.1  grDevices_4.4.1
  highr_0.11      knitr_1.48      methods_4.4.1  
  stats_4.4.1     tools_4.4.1     utils_4.4.1    
  xfun_0.47       yaml_2.3.10    
@yihui
Copy link
Owner

yihui commented Sep 20, 2024

For 1, I don't know how to reproduce the problem. Could you please follow the issue guide and at least provide xfun::session_info('knitr')?

For 2, I think that's more of an issue with the citation styles. I've also run into this issue before, and I felt the citation style was too aggressive when changing the first letters of words into lowercase. Such transformations are almost impossible be perfect, therefore my humble option is that they just should not do it. For R packages, I have never seen anyone put {} around R in the package DESCRIPTION.

@fkohrt
Copy link
Contributor Author

fkohrt commented Sep 20, 2024

Concerning (1): I added the output of xfun::session_info('knitr') in the original post and now also provide the options() that make the warning appear. Sorry for this omission.

Concerning (2): Pandoc, by default, uses the Chicago Manual of Style, which changes the casing of R to r, probably for the many users that don't change the default. The other citations that are generated by toBibtex(citation("knitr")) do have R wraped in curly braces.

@fkohrt
Copy link
Contributor Author

fkohrt commented Sep 20, 2024

Concerning (1), the warning vanishes if I try it with the latest development version. Sorry for not trying that in the first place.

@yihui
Copy link
Owner

yihui commented Sep 20, 2024

Concerning (1), the warning vanishes if I try it with the latest development version. Sorry for not trying that in the first place.

No worries, but actually the warning vanished just by chance: if you install from Github, the object meta won't have a Date or Date/Publication field.

I was trying to figure out how meta could have the Date/Publication field and haven't succeeded on macOS. I wonder if it's specific to Linux.

The other citations that are generated by toBibtex(citation("knitr")) do have R wraped in curly braces.

The package citation was generated automatically from the package DESCRIPTION, whereas other citation entries were provided manually (and I added {} around R): https://github.com/yihui/knitr/blob/master/inst/CITATION

@yihui yihui closed this as completed in 2dc1e4a Sep 20, 2024
@yihui
Copy link
Owner

yihui commented Sep 20, 2024

I figured out the partial matching problem.

For R without {}, you need to either use a citation style won't convert it to lowercase, or post-process the toBibtex() results (e.g., gsub()).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants