GeoBosh / rbibutils

Convert bibliography files between various formats, including BibTeX, BibLaTeX, PubMed, RIS, and Bibentry. This is an R port of the bibutils utilities plus R manipulation of bibiliography objects.
https://geobosh.github.io/rbibutils/
13 stars 1 forks source link

Inaccurate conversion of `\emph` in bibtex entries #3

Open aravind-j opened 3 years ago

aravind-j commented 3 years ago

In case of bibtex entries with italicized codes specified using \emph{}, rbibuitils is converting backslash in \emph to \backslash, resulting in \backslashemph leading to a unknown macro '\backslashemph' error.

bib1 <- "@article{burton_quantitative_1951,
    title = {Quantitative inheritance in pearl millet (\\emph{{Pennisetum} glaucum})},
    volume = {43},
    number = {9},
    journal = {Agronomy Journal},
    author = {Burton, Glenn W.},
    year = {1951},
    pages = {409--417}
}"

bib2 <- "@article{diwan_methods_1995,
  title = {Methods of developing a core collection of annual \\emph{{Medicago}} species},
  volume = {90},
  language = {en},
  number = {6},
  journal = {Theoretical and Applied Genetics},
  author = {Diwan, N. and McIntosh, M. S. and Bauchan, G. R.},
  month = may,
  year = {1995},
  keywords = {Annual Medicago species, Core collection, Germplasm collection, Relative Diversity method},
  pages = {755--761}
}"

rbibutils::charToBib(bib1)
#> Burton GW (1951). "Quantitative inheritance in pearl millet
#> (\backslashemph{{Pennisetum} glaucum})." _Agronomy Journal_, *43*(9),
#> 409-417.
rbibutils::charToBib(bib2)
#> Diwan N, McIntosh MS, Bauchan GR (1995). "Methods of developing a core
#> collection of annual \backslashemph{{Medicago}} species." _Theoretical
#> and Applied Genetics_, *90*(6), 755-761.
GeoBosh commented 3 years ago

Thanks for the report, I will fix it.

Interestingly, the CRAN version of EvaluateCore contains entries with \emph{} but passes the checks on CRAN. Maybe those entries were unused in that version of EvaluateCore.

aravind-j commented 3 years ago

That is interesting, but the problematic entries with \emph{} (diwan_methods_1995, basigalup_development_1995, tai_core_2001 and studnicki_comparing_2013) were being used in the documentation.

GeoBosh commented 3 years ago

This comment is mainly for me. Maybe it would be best to change the call in Rdpack to use direct = TRUE. With the above objects bib1 and bib2 it gives:

rbibutils::charToBib(bib1, direct = TRUE)
## Burton GW (1951). “Quantitative inheritance in pearl millet
## (_Pennisetum glaucum_).” _Agronomy Journal_, *43*(9), 409-417.
rbibutils::charToBib(bib2, direct = TRUE)
## Diwan N, McIntosh MS, Bauchan GR (1995). “Methods of developing a core## 
## collection of annual _Medicago_ species.” _Theoretical and Applied
## Genetics_, *90*(6), 755-761.
GeoBosh commented 3 years ago

I updated Rdpack on github to use option direct = TRUE, as in the example in my previous comment. This should resolve the issue for Rdpack users and was the plan anyway. I am leaving this issue open since it should be fixed for the case direct = FALSE.

I believe that if you build your package with the github version of Rdpack it will pass the CRAN checks. I have checked the reverse dependencies of Rdpack with the versions of rbibutils on CRAN and github and all pass on my system (ubuntu 20.04) but it may take some time before submitting to CRAN.

GeoBosh commented 3 years ago

The above change in Rdpack is on CRAN (version 2.1.2).