Set links on custom bibtex-keys with bibtex OR biblatex

Long time ago, while working on my thesis I fumbled with bibtex (do NOT do this) that creates bibliographies from *.bib files using a horrible stack-based scripting language for the styling. I wanted to have references directly linked to the matching articles in the web as many scientific journals do, see e.g. Nature Materials (hyperlink in blue):


Citation style of Nature Materials

You can do that either by using the URL directly or resolve the digital object identifier (DOI) via DOIs are very useful, if you can get them. See e.g. this article.

So my task was to implement that using bibtex (biblatex was not very common at that time). I succeeded, by introducing some linker function, named link_it, which was able to set an appropriate link on some sequence of bibtex-keys that were processed with bibtex. For technical details look at the custom style file unsrtnat_abbrv_link_it.bst on and search for that linker-function. Also see this article. However, here is how it looks like (hyperlink in green):


BibTeX reference using the style file unsrtnat_abbrv_link_it.bst found at

and here is how you use it:


Quite simple, apart from the difficulties altering the style file. However, every slight change involves stack-based horrors again, so better use the new approach with the biblatex package. For later works I used that with great success, so this is what I wanted to share with you today.

The result with the near-default style with the linker-function in it looks somewhat different from the one of natbib (hyperlink again in green):

Reference style created by the biblatex package

A bit longer is the piece of code that you have to add to your Header.tex file. But note, that you only need LaTeX-code here. Customization does not involve bibtex-style files! Okay, some of you might say that LaTeX code is also horrible to write at some deeper level. That’s true. But if you take this as an argument towards old-style bibtex, I would just say, you know nothing [John Snow].

% bibliography file
% clear some fields
% define a link format for arbitrary bibtex keys
% if hyperref is used, set doi/url links
% if not url and not doi, print without link
% use url only if doi is NOT present
% if doi is present, set a link on the key
% if no hyperref, do not link
% format settings
\DeclareFieldFormat[book,incollection]{isbn}{% set url link on ISBN
\mkbibacro{ISBN}\addcolon\space \usebibmacro{link_it}{#1}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}} % number in brackets
\DeclareFieldFormat[article]{pages}{#1} % do not add anything to pages
\renewbibmacro{in:}{} % suppress "in:"
% define a "volume(number):pages" key
\clearfield{pages} % pages used, where not intended, clear field
% use "et al."
andothers={et\addabbrvspace al\adddot}}

I’m very hapy with this now. Another pro for biblatex is, that you only have to compile once, not twice, to update your bibliography. You may also have multiple bibtex-ressource files.

Feel free to comment or to use the code above. As always: everything CC BY-NC-SA 🙂


Peter Pan. Kann fliegen mit Feenstaub.

Tagged with: , , , ,
Posted in Technik

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Posts by topic…
…by month
Have a look at…

%d bloggers like this: