1

I would like to have the doi shown in the bibliography as a single link, i.e. it should be shown as an hyperlink with title doi instead of printed as doi:10.1038/s1231.

I found the nice urlbst, which allowed to take any bib style and have the doi printed as text, using: urlbst --doi --hyperref style.bst styleNew.bst This even nicely prints doi:10.1038/s1231 while adding a hyperlink with https://doi.org/10.1038

To have doi shown as hyperlink, I tried \renewcommand{\url}[1]{\hyperlink{#1}{doi}}, however I am facing two issues:

  • This only works for bibtex URL fields, not doi fields
  • This actually prints URLs, while I would like only to show dois.

Thanks!

1 Answer 1

3

If you're willing to indulge in a bit of bst style-hacking, then you could take your .bst file, as generated by urlbst, and make the following replacement:

FUNCTION {format.doi}
{ doi empty$
    { "" }
    %{ doiprefix doi * doiurl doi * make.href }
    { "doi" doiurl doi * make.href }
  if$
}

(that is, replacing the commented-out line with the line below it).

That appears to produce the formatting you're looking for, with just ‘doi’ as the link text.

Hmm: it occurs to me that urlbst could make this easier. There are already a couple of settings advertised at the top of the generated .bst files. It wouldn't be unreasonable to add a further switch to have the .bst files generate \doi{<content-of-doi-field} instead of what they do now. Looking at my diary, it looks like I'll have some urgent procrastination coming up, so...

9
  • this works perfectly, thanks! Is there a way to only add the doi, and not the URL?
    – Matifou
    Commented Nov 28, 2022 at 12:40
  • Do you mean displaying only the DOI, but not making it a hyperlink? You should be able to get that by making the fifth line, above, just { doi }. Commented Nov 28, 2022 at 12:52
  • Sorry, I mean only considering the doi field of the bibtex, not the url one (they tend to be redundant).
    – Matifou
    Commented Nov 28, 2022 at 13:38
  • @Matifou I've released v0.9 of urlbst, which includes a switch when running urlbst (namely --setting doiform 1) which will generate the DOI as \doi{xxx}, which means that you can define a \doi macro however you wish. It's a bit of a general escape-hatch, but might give the flexibility you need. Thanks for the (implicit) suggestion! Commented Dec 5, 2022 at 17:16
  • awesome, thanks a lot for your great work!
    – Matifou
    Commented Dec 6, 2022 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .