# Remove brackets around special characters in URL in bibliography entries

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.
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
fontsize: 11pt
linestretch: 1.2
documentclass: book
bibliography: [packages.bib, library.bib]
---

• 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

• @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
• @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