7

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.

4

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}

example output with correct URL

0

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.

  • 4
    Actually, 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. – Sean Allred May 31 '15 at 12:15
  • It 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. – wondering May 31 '15 at 12:47
  • 3
    And people wonder why I prefer to write my documents straight-up… It sucks when the tool is your problem. – Sean Allred May 31 '15 at 12:48
  • @SeanAllred I got enchanted by sever features of Mendeley that I really like. That might have been a mistake. – wondering May 31 '15 at 13:31
  • 1
    What other special characters need special treatment? If it's just generic Unicode stuff, use biber/biblatex. – Sean Allred May 31 '15 at 13:56

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.