TransWikia.com

BibTeX code to create hyperlinks from either DOI or URL

TeX - LaTeX Asked by mrupp on December 27, 2020

Currently, I use below code (from StackExchange) to ‘linkify’ parts of BibTeX entries:

FUNCTION {doilink}
{ duplicate$ empty$
  { pop$ "" }
  { doi empty$
      { skip$ }
      { "href{https://doi.org/" doi * "}{" * swap$ * "}" * }
    if$
  }
  if$
}

Appending this command to, e.g., the code for format.title formats the title as a hyperlink:

FUNCTION {format.title}
{ title
  duplicate$ empty$ 'skip$
    { "t" change.case$ }
  if$
  "title" bibinfo.check
  duplicate$ empty$ 'skip$
    {
      emphasize
    }
  if$
  doilink
}

Question: How can I change the doilink code to use the url field when there is no doi field, and to do nothing if both are not present?

The solution should work with BibTeX (in particular, it should not require biblatex).

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP