1

I am creating a pdf book in RStudio using bookdown with natbib, and cite with [@reference] from a .bib file created with mendeley. Also, I use the \setcitestyle{numbers,square,comma} style.

For all references that has an URL, all special characters, such as _ and % are wrapped in brackets inside the URL, like this:

Jennifer M Andrews. Determination of minimum inhibitory concentrations. Journal
of Antimicrobial Chemotherapy, 48(suppl_1):5–16, jul 2001. ISSN 1460-2091.
doi: 10.1093/jac/48.suppl_1.5. URL http://academic.oup.com/jac/article/48/
suppl{_}1/5/2473513/Determination-of-minimum-inhibitory-concentrations.

I have read this post similar to my issue, but I do not have issues with line breaks, as the references look fine except the {} wrapping the special characters. Is there any way to make this work with natbib? I have also tried using the url package, which makes no difference.

I have also tried to remove mendeley's option to escape special characters, but then the book fails to render.

My YAML:

site: bookdown::bookdown_site
geometry: "left=4cm,right=3cm,top=3cm,bottom=3cm"
subparagraph: true
output:
  bookdown::pdf_book:
    toc: false
    citation_package: natbib
    includes:
      before_body: frontpage.tex
      after_body: after_body.tex
      in_header: preamble.tex
fontsize: 11pt
linestretch: 1.2
documentclass: book
bibliography: [packages.bib, library.bib]
link-citations: yes
---
  • What does the .bib entry for the bibliography item look like? Does it already contain the escape characters? In that case, things are going to be tricky, because removing them is not going to be particularly simple. Mendeley isn't known for producing good-quality .bib files, so you may want to think about switching to a different tool (Zotero?) or may have to accept post-processing your .bib files. – moewe Sep 5 at 15:32
  • Mendeley's aggressive character escaping might also explain the problems in your other question: tex.stackexchange.com/q/507006/35864. If Mendeley escapes the \ and {, } in \emph{E. coli}, then that would explain why things don't work as expected. – moewe Sep 5 at 15:34
  • @moewe Thank you for your comments and suggestions. I will try to switch to Zotero, maybe that will fix things – Haakonkas Sep 6 at 9:11
1

This was fixed by creating the same .bib file with Zotero instead of Mendeley

  • @BambOo Please did you read the question and the comment under the question? Then you can see that is an answer ... :-) – Mensch Sep 6 at 11:46
  • @Mensch, yes I did. I'm just not so sure about this being an answer (though posted by the OP) as it is a workaround. Maybe some users won't be able to switch from Mendeley to Zotero ? – BambOo Sep 6 at 11:51
  • @BambOo It's pretty much the best thing one can do in this situation. Mendeley generates mangled .bib files. It is much better to switch to a tool that generates sane .bib files than to try and work around the output Mendeley produces. – moewe Sep 6 at 12:05
  • @moewe So the best thing is to not use Mendeley ? :) – BambOo Sep 6 at 12:07
  • @BambOo If I want to produce usable .bib files, my experience (which is mostly second-hand through this site, mind you) has been that Mendeley would not be the tool of my choice. Zotero (especially with Better BibTeX) usually produces better .bib files (and has very responsive developers). So I guess I'm saying yes. – moewe Sep 6 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.