Issue: BibTeX Export and Amperstand's in URLs

Hello,

I'm running into an issue using my exported BibTeX files for citations in LaTeX. Some repositories (such as ScienceDirect) have URL's with amperstands in them. When compiling the BibTeX file with these URL's, this error is reported:



...\url{http://www.foo.com/foo/michaels&foo}
\end{APACrefURL}

I can't figure out why you would want to use a tab mark
here. If you just want an ampersand, the remedy is
simple: Just type `I\&' now.



The obvious solution for me at this point is to either remove the URL from Zotero, or remove the URL field from the BibTeX file. However, I'd prefer not to have to edit those in order to get a working BibTeX file.

Any advice or a fix would be greatly appreciated.
  • I don't know the BibTeX details here, but this thread states that no escaping should be done for the URL field, which appears to be the current behavior. Is this incorrect?
  • It seems to be necessary. Escaping the ampersand fixes this issue; I know that percentage signs should be escaped, as well (since they are comment start characters in LaTeX). The ampersand, similarly, has a function in LaTeX (tab separation perhaps?) and using them in the url field seems to require the same escaping as in the other fields in BibTeX and LaTeX generally.

    This article has a good table on escaping characters in LaTeX: http://libraries.mit.edu/help/refworks/refworkslatexfaq.html

    And this post indicates that, in some instances, escaping in URLs in needed: http://osdir.com/ml/kde.tellico.general/2007-05/msg00060.html
  • I think that if you use the url package in conjunction with (e.g.) natbib,
    this problem will be resolved.

    This example works for me:

    test.tex:

    \documentclass{article}
    \usepackage{natbib}
    \usepackage{url}
    \begin{document}
    \bibliographystyle{plainnat}

    \cite{abc}

    \bibliography{test}
    \end{document}

    test.bib:

    @Article{abc,
    author = {A. Bee},
    title = {Whatever},
    journal = {J. Whatever},
    year = {2009},
    url = {\url{a&+%^b}}
    }
  • Oops. That \url in the url field of test.bib isn't necessary.
  • Nope, still doing it in natbib, too, and I've tried other LaTeX formats with the same issue. Again, escaping the ampersand fixes this issue consistently and the output is perfect. Seems that it does require escaping.
  • bbolker's example works for me. Neither JabRef nor bibutils escapes ampersands. It may be a problem with either apacite or url--I haven't played much with it.
  • Maybe I'll play with some other citation styles and see if I can figure it out.
Sign In or Register to comment.