Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using biblatex together with a bibliography manager Referencer. I want to use the url field of the bib file to link to the page. However, Referencer has urls of the form

url = {{ http://... }}

rather than the usual format with only a single brace. Url fields are interpreted literally in biblatex and so I get links to { http:// ... } in the pdf and they consequently do not work. Since every time I change the bibliography file through Referencer the curly braces reappear, going through the bib file and removing the extra braces is not a solution for me. Is there a way to tell LaTeX to automatically remove the braces before passing the result to \href?

share|improve this question
2  
Why is Referencer doing this: it's wrong. –  Joseph Wright Aug 19 '12 at 10:40
    
I think it's because URL is a custom field in Referencer and it adds double braces to all of the custom fields if you want it to add double braces to other fields (such as title), where they are desirable. You can set this via the option "Protect capitalization". But if I switch this off I won't get double braces anywhere. –  SMeznaric Aug 19 '12 at 11:12
    
Taking a look at how Referencer works, it seems that when you select 'Protect capitalization' it adds braces around the entire content of almost every field. I would say that this is not a good idea: braces should be used only where needed. I would suggest using a BibTeX-focussed manager, such as JabRef. –  Joseph Wright Aug 19 '12 at 11:32
    
Yes, I agree it is a bad idea. Is there no way to do string processing in LaTeX and remove the braces that way? –  SMeznaric Aug 19 '12 at 13:49
add comment

1 Answer 1

up vote 12 down vote accepted

Make sure you are using biblatex 2.0+ and biber 1.0+ and put this in your preamble:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url,
            match=\regexp{\A\{(.+)\}\z},
            replace=$1]
    }
  }
}

Of course the regexp can be tuned to your liking. See section 4.5.2 of the current biblatex manual.

share|improve this answer
    
This works. Thank you very much. –  SMeznaric Aug 19 '12 at 17:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.