Hash symbol in URLs

Hello,
I was wondering how I can set up Zotero to automatically backslash all hash symbols (#) in a URL when exporting to BibTeX? Otherwise, I need to manually go through the bib file and manually backslash or add \url{...} to the URL string.

My specific use case is to use Zotero connector on https://ui.adsabs.harvard.edu/ abstracts to create an entry and then sync my bibliography to an overleaf file. However, as the URL always has a "#" in it: https://ui.adsabs.harvard.edu/#abs/2003ApJS..148..175S/abstract, I have to manually go through entries and add the backslash.

How do I make Zotero output BibTeX with either \url{...} wrapping URLs, or backslash on the # symbols?

Thanks!
Miles
  • Is using BibLaTex/biber an option? That should just work.

    The URL handling in bibtex is just so bizarre and I'm still not sure what's right/recommended here. The general consensus seems to be against escaping special characters in URLs. Moreover, the \url{} wrap of the URL field can be applied by the .bst style in bibtex and that's a more flexible solution (allowing for other styling such as hyperref etc).

    For your question specifically, if you rely on Overleaf's Zotero integration, which runs through the API, there's no way you can change this. If you export Zotero bib files locally and then import into Overleaf you could a) look if BetterBibTeX handles this differently or b) you'd have to modify the javascript file that handles Zotero's bibtex output, which is a good bit more involved.
  • In biblatex, it's supported. Just generally, use biblatex if you can.

    In bibtex, it depends. I export it as "\url{...}"; inside "\url{...}", verbatim rules apply, which for bibtex means "#\%&{}" must all be escaped (IIRC). For bibtex, you'd generally also want to replace unicode chars (rare in URLs but not impossible)
  • inside "\url{...}", verbatim rules apply, which for bibtex means "#\%&{}" must all be escaped (IIRC).
    I thought the opposite? inside \url they need not be escaped?
  • I could be wrong on the list (this is just what I ended up with through error reports, I've never found good docs for this), but at least something must be escaped (like braces).
  • edited December 14, 2018
    I've tried to find the test case in question but so much got changed in the Z5 port that I don't have a clear sense of when it was introduced in the git history.
Sign In or Register to comment.