DOI + ARXIV'S EPRINT + URL; BIBTEX/BST HOWTO

The latest version of this page is located at /~comech/tools/bibtex-doi-eprint/


OBJECTIVE

To create DVI/PDF files with the bibliography which contains a hyperlink to the paper based on URL or DOI or EPRINT fields of the bibtex entry.

The end result will look something like this:

A. G. Lisi, A solitary wave solution of the Maxwell-Dirac equations, J. Phys. A 28 (1995), 5385--5392.


Alternative (it failed to work for me): urlbst.

QUICK START


STEP 0

The expected entries in your file.bib is of the form as found on adsabs.harvard.edu or at arxiv.org. For example,

@ARTICLE{1995JPhA...28.5385L,
   author = {{Lisi}, A.~G.},
    title = {A solitary wave solution of the {M}axwell-{D}irac equations},
  journal = {Journal of Physics A Mathematical General},
     year = 1995,
    month = sep,
   volume = 28,
    pages = {5385--5392},
      doi = {10.1088/0305-4470/28/18/026},
   adsurl = {http://adsabs.harvard.edu/abs/1995JPhA...28.5385L},
   eprint = "hep-th/9410244",
      URL = {http://stacks.iop.org/0305-4470/28/5385},
}
The hyperlink will be based on the URL field or DOI field or EPRINT field (in this order).

STEP 1

In your favorite .bst file (such as one of BST files from natbib package), make the changes to the following parts (the additions are in bold color):
----
ENTRY
  { address
    author
    ...
    year
    doi %% MAKE SURE THE ENTRIES DO NOT REPEAT!
    eprint %% MAKE SURE THE ENTRIES DO NOT REPEAT!
    url %% MAKE SURE THE ENTRIES DO NOT REPEAT!
  }
...

FUNCTION {format.vol.num.pages}
{ volume field.or.null
  duplicate$ empty$
    {%% IF YOU WANT THE EPRINT NUMBER TO SHOW UP LIKE THIS: ArXiv e-prints 1501.1234 (2015)
      eprint empty$
        { }
        { "\href{http://arxiv.org/abs/" eprint * "}{" * swap$ * eprint * "}" * }
      if$
    }
    {
      "volume" bibinfo.check
    }
  if$
  bolden
  format.year *
  eid empty$
    { format.journal.pages }
    { format.journal.eid }
  if$
}


FUNCTION {format.title}
{ title
  duplicate$ empty$ 'skip$
    { "t" change.case$ }
  if$
  "title" bibinfo.check
  duplicate$ empty$ 'skip$
    {
      emphasize
    }
  if$
  url empty$
    {
    doi empty$
      {
      eprint empty$
        { }
        { "\href{http://arxiv.org/abs/" eprint * "}{" * swap$ * "}" * }
      if$
      }
      { "\href{http://dx.doi.org/" doi * "}{" * swap$ * "}" * }
    if$
    }
    { "\href{" url * "}{" * swap$ * "}" * }
  if$
}
...

----

Make similar changes in FUNCTION {format.title}, FUNCTION {format.btitle}, and FUNCTION {format.in.ed.booktitle}.

Optionally, comment the lines which add DOI, URL, and ISSN things to the bibliography:

   %format.issn output
   %format.doi output
   %format.url output

To have a better idea about what is going on, have a look at stackoverflow.com/questions/3546396/bib-style-format-for-bibtext-bst-file-explained-by-an-example


STEP 1A

Alternatively, you can try to use the script add-doi-support which supposedly does the same:
./add-doi-support bstfile.bst bstfile-doi.bst

STEP 2

Remember to use \bibliographystyle{bstfile-doi} in your file.tex and run
latex file.tex
bibtex file.aux
A *.bbl file will be created with the \doi or \eprint or \href entities, like this:

\bibitem[Lis95]{MR1364144}
A.~G. Lisi, \href{http://stacks.iop.org/0305-4470/28/5385}{{\em A solitary wave
  solution of the {M}axwell-{D}irac equations\/}}, J. Phys. A {\bf 28} (1995),
  pp. 5385--5392.
If there is no URL field in the bibtex entry, but the DOI field is present, there will be
\href{http://dx.doi.org/10.1088/0305-4470/28/18/026}{{\em ...}}

If there is no DOI field in the bibtex entry, but the EPRINT field is present, there will be
\href{http://arxiv.org/abs/hep-th/9410244}{{\em ...}}


STEP 3

If you are frightened by the default colors of hyperref package and/or want to disable back-referencing in the bibliography, make the following additions at the top of your file.tex:

%% The Package aas_macros contains shortcuts like \def\prd{\ref@jnl{Phys.~Rev.~D}}
%% used in ADSABS database,
%\usepackage{aas_macros}
\usepackage[backref=none]{hyperref} %% To make sure backref is disabled
\usepackage[usenames,dvipsnames]{color}
%% Disable backref and make \href colors more decent:
\definecolor{MyDarkBlue}{rgb}{0,0.1,0.7}
\hypersetup{pdfborder={0 0 0},colorlinks,breaklinks=true,
  urlcolor={MyDarkBlue},citecolor={MyDarkBlue},linkcolor={MyDarkBlue} }


Written by Andrew Comech