3

I am using Overleaf and Mendeley in sync. This is very convenient as my library in Mendeley is directly available in my overleaf documents in a references.bib document.

However when DOIs from mendeley are imported, _ are escaped and looks like {\_}that leads to broken links in the compiled file.

The sync file is not editable unfortunately. So I am looking for a way to unescape these caracters.

Thanks for your help !

MWE :

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[doi=true]{biblatex}

\RequirePackage{filecontents}
\begin{filecontents}{ref.bib}
@article{Williamson.1968,
 author = {Williamson, Oliver E.},
 year = {1968},
 title = {Economies as an Antitrust Defense: The Welfare Tradeoffs},
 doi={12.803/bla{\_}327}
}

\end{filecontents}

\addbibresource{ref.bib}

\begin{document}

\nocite{*}

\printbibliography
\end{document}
3
  • I would suggest bringing this up with Overleaf support. It's barely on topic here I think. Or if this is done by Mendeley directly whenever they export bibtex, then with their support.
    – Alan Munn
    Mar 17, 2021 at 20:31
  • It looks like it is an overleaf issue. I'll bring this up with their support. In the meanwhile, moewe's answer does the job for me.
    – nlair
    Mar 17, 2021 at 20:46
  • Even though this is Mendeley's problem and not Overleaf's, bringing it up with Overleaf might be a better route anyway. If Overleaf is committed to Mendeley integration, they might just have the clout the pressure Mendeley to fix this, so I would take the time to raise it with them.
    – Alan Munn
    Mar 17, 2021 at 21:32

2 Answers 2

4

A software that claims to support biblatex should export DOIs and URLs unchanged and without LaTeX escaping. (This is also true for most BibTeX styles that support a dedicated doi or url field. It should never be necessary to escape special characters like _ in a field like url or doi: The style should handle these things by using commands like \url that can accept _.) Complain to Mendeley support.

If you absolutely must stick with Mendeley and they refuse to fix this issue, you can use a Biber sourcemap to fix the broken entries

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[doi=true]{biblatex}

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=doi,
        match=\regexp{\{\\_\}},
        replace=\regexp{_}]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@article{Williamson.1968,
  author = {Williamson, Oliver E.},
  year   = {1968},
  title  = {Economies as an Antitrust Defense: The Welfare Tradeoffs},
  doi    = {12.803/bla{\_}327}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\printbibliography
\end{document}

Oliver E. Williamson. “Economies as an Antitrust Defense: The Welfare Tradeoffs”. In: (1968). doi: 12.803/bla_327.

You'll need a similar line for all characters mangled by Mendeley's exporter.

2
0

I found this question quite recently, and unfortunately, I could not use the solution presented here due to the incompatibility of packages. I was using the cite package with backref, which does not work with biblatex. In the end I could solve my problem by using latexmkrc within overleaf. My issue was that a title containing effectively {$\mathbb{ab}$} became mangled. Here is my latexmkrc code if it is of use to anyone else:

system("sed -i 's/{\\\\textbackslash}/\\\\/g' ./references.bib");
system("sed -i 's/{\\\\}}/}/g' ./references.bib");
system("sed -i 's/{\\\\{}/{/g' ./references.bib");
system("sed -i 's/{\\\\^}/^/g' ./references.bib");
system("sed -i 's/{\\\\^{}}/^/g' ./references.bib");
system(q"sed -i 's/{\\\$}/$/g' ./references.bib");

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .