5

For each paper at SAO/NASA Astrophysics Data System (ADS) a BibTeX entry is provided containing a field like

adsurl = {http://adsabs.harvard.edu/abs/2015EPJST.224.2217S},

which I would like to add as link in the bibliography of my LaTeX document.

It seemed like there is no simple way to do this in BibTeX but that it should be possible with biblatex. How?

  • 1
    If you use BibTeX, which bibliography style do you employ? – Mico Jan 9 '16 at 2:48
  • I use different styles for example aa.bst. – Frank Breitling Jan 11 '16 at 11:08
3

In biblatex it is possible to define new bibtex fields. New fields can be created using \DeclareDatamodelFields and \DeclareDatamodelEntrytypes (these commands should appear in a biblatex configuration file, a simple ways is to is to use filecontents to create such configuration file while processing a document)

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=verbatim]{adsurl}
\DeclareDatamodelEntryfields[proceedings,inproceedings]{adsurl}
\end{filecontents}

The second step is to specify how it is going to be rendered. For example,

\DeclareFieldFormat{adsurl}{#1}

and then add

\printfield[bibhyperref]{adsurl} 

in the drivers/bibmacro for the entries where the field should be printed. The following simply add the adsurl at the end of an bibliography entry in the bibliography.

\newbibmacro{finentry}{\printfield[bibhyperref]{adsurl}\finentry}
  • 1
    Note that if you override the default field format with the optional argument as in \printfield[bibhyperref]{adsurl} there is no point in having a \DeclareFieldFormat{adsurl}{#1} in the first place. Furthermore, I think bibhyperref is not the correct format here, it is used to link back to the bibliography entry form a citation. I would probably go \DeclareFieldFormat{adsurl}{\mkbibacro{ADSURL}\addcolon\space\url{#1}} \renewbibmacro{finentry}{\printfield{adsurl}\finentry} or so. Instead of the datatype verbatim one could even use uri. – moewe Jan 9 '16 at 9:06
  • Thank you very much for your answer, which seems to work. But is \DeclareDatamodelEntryfields actually needed? Is there also a way to remove "adsabs.harvard.edu/abs" from every entry? – Frank Breitling Jan 11 '16 at 10:58
2

This is a workaround just for the A&A journal. I modified aa.bst file and use the adsurl entry and doi entry to create clickable hyperlinks. You can download the new aa_url.bst here: https://github.com/yangcht/AA-bibstyle-with-hyperlink

just replace the aa.bst with aa_url.bst

An example is here: enter image description here

Note that do please use the bib entry generated by the ADS website.

0

It seems like I found a satisfying solution based on an additional comment in How can I cut, strip, truncate or rename parts of bibtex fields with biblatex. Now it looks as follows:

\usepackage[natbib=true,style=authoryear,maxbibnames=5,minbibnames=5]{biblatex}

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=verbatim]{adsurl}
\DeclareDatamodelEntryfields{adsurl}
\end{filecontents}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=adsurl, match={http://adsabs.harvard.edu/abs/},
        replace={}]
    }
  }
}

\DeclareFieldFormat{adsurl}{ADSURL: \href{http://adsabs.harvard.edu/abs/#1}{#1}}

\renewbibmacro{finentry}{\printfield{adsurl}\finentry}

\let\cite\textcite  %for compatibility of \cite/\citep with bibtex

And it produces something like:

Kundu, M. R. (1965). Solar radio astronomy. New York: Interscience Publication,
1965. ADSURL: 1965sra..book.....K.

where 1965sra..book.....K is a link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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