If a link in an url contains ~
, Mendeley changes it to $\sim$
and hyperref
links just don't work. I use pdflatex and biblatex.
Is there a quick way how to change manually the link in Mendeley to fix this? Editing manually the library.bib
file exported by Mendeley is not an option for me.
-
Related: tex.stackexchange.com/q/10858/17423– Sean AllredCommented May 31, 2015 at 12:14
2 Answers
This is definitely something you need to address on a Mendeley level, the software needs to make sure it exports correct .bib
files, and http://example.edu/$\sim$elk/bronto.pdf
is hardly correct. URLs should be exported verbose without any modifications.
But with Biber's sourcemapping we can try and save your file, let's say you have
@online{bronto,
author = {Anne Elk},
title = {Towards a Unified Theory on Brontosauruses},
date = {1972-11-16},
url = {http://example.edu/$\sim$elk/bronto.pdf},
urldate = {2015-09-07},
}
Then
\DeclareSourcemap{
\maps{
\map{
\step[fieldsource=url,
match=\regexp{\$\\sim\$},
replace=\regexp{\~}]
}
}
}
will turn that $\sim$
back into a ~
.
MWE
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{bronto,
author = {Anne Elk},
title = {Towards a Unified Theory on Brontosauruses},
date = {1972-11-16},
url = {http://example.edu/$\sim$elk/bronto.pdf},
urldate = {2015-09-07},
}
\end{filecontents*}
\documentclass{article}
\usepackage{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps{
\map{
\step[fieldsource=url,
match=\regexp{\$\\sim\$},
replace=\regexp{\~}]
}
}
}
\begin{document}
\nocite{bronto}
\printbibliography
\end{document}
So, one simply has to replace in the url in Mendeley ~
with \textasciitilde{}
. Then it works. Note that I have the option "do not escape latex special characters" in Mendeley.
-
4Actually, you should just be able to load the
hyperref
package in your document. If there's a way to just make Mendeley not do anything with~
, that'd be best. Commented May 31, 2015 at 12:15 -
1It is possible to tell Mendeley not to do anything with ALL special characters in all fields. But not separately in the
url
field. That's the problem. Commented May 31, 2015 at 12:47 -
3And people wonder why I prefer to write my documents straight-up… It sucks when the tool is your problem. Commented May 31, 2015 at 12:48
-
@SeanAllred I got enchanted by sever features of Mendeley that I really like. That might have been a mistake. Commented May 31, 2015 at 13:31
-
1What other special characters need special treatment? If it's just generic Unicode stuff, use
biber
/biblatex
. Commented May 31, 2015 at 13:56