-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
feature request: tweak non-escaped ampersand #2335
Comments
Thanks for the report. This is indeed an issue with ---
title: "test"
output:
pdf_document:
keep_tex: true
citation_package: natbib
bibliography: packages.bib
---
```{r}
knitr::write_bib(x = "spam", "packages.bib")
```
@spam2017
leads to
while no error if the default is used (meaning Pandoc citeproc handles the citation processing for PDF)
Though, as you noticed, this comes directly from They have a
It doesn't not help here with toBibtex(citation("spam"), espace = TRUE)
#> @Manual{,
#> year = {2023},
#> title = {{spam}: SPArse Matrix},
#> author = {Reinhard Furrer and Roman Flury and Florian Gerber},
#> note = {R package version 2.10-0},
#> url = {https://CRAN.R-project.org/package=spam},
#> }
#>
#> @Article{,
#> title = {{spam}: A Sparse Matrix {R} Package with Emphasis on {MCMC} Methods for {G}aussian {M}arkov Random Fields},
#> author = {Reinhard Furrer and Stephan R. Sain},
#> journal = {Journal of Statistical Software},
#> year = {2010},
#> volume = {36},
#> number = {10},
#> pages = {1--25},
#> doi = {10.18637/jss.v036.i10},
#> }
#>
#> @Article{,
#> title = {Pitfalls in the Implementation of {B}ayesian Hierarchical Modeling of Areal Count Data: An Illustration Using {BYM} and {L}eroux Models},
#> author = {Florian Gerber and Reinhard Furrer},
#> journal = {Journal of Statistical Software, Code Snippets},
#> year = {2015},
#> volume = {63},
#> number = {1},
#> pages = {1--32},
#> doi = {10.18637/jss.v063.c01},
#> }
#>
#> @Article{,
#> title = {Extending {R} packages to support 64-bit compiled code: An illustration with spam64 and {GIMMS} {NDVI3g} data},
#> author = {Florian Gerber and Kaspar Moesinger and Reinhard Furrer},
#> journal = {Computer & Geoscience},
#> year = {2017},
#> volume = {104},
#> pages = {109--119},
#> issn = {0098-3004},
#> doi = {10.1016/j.cageo.2016.11.015},
#> } It seems to be an issue in R utils function after all. 🤔 @yihui what do you think ? |
We can probably escape gsub('(?<!\\\\)&', '\\\\&', x, perl = TRUE) We need to verify if |
Ok! Is that an encouragement to me or @cderv to submit a PR? |
Either of us I would say :) Feel free to contribute if you are interested. Do you want to give it a try ? |
I could... but.. I have a deadline for a paper on Sunday and 53 exams to grade and I haven't edited knitr source code before. I think you're probably going to do it better and faster ;) |
I totally get the workload you're juggling right now – the paper deadline and all those exams to grade must be keeping you super busy! Don't worry; It was appreciated you were willing to. We'll do it. Thanks again for opening the issue |
Thanks!! |
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
For reasons beyond my understanding, some bibtex entries generated by citation() from Description files have non-escaped ampersands - which causes problems with LaTeX later.
See for example spam2017 below.
Currently, I'm doing a fairly "hacky" solve to this by reading in the output from write_bib and then doing some find and replace with stringr.
Could knitr::write_bib please check for non-escpaped ampersands and do this tweak if necessary?
Thank you! Love the package!
The text was updated successfully, but these errors were encountered: