8

I have seen on several occasions in some texts nicely formatted bibliographies which included hyperlinks to MR, Zbl and arxiv, sometimes doi, for example, something that looked approximately like this (copied from this paper):

  • Boris Albar and Daniel Gonçalves. On triangles in Kr-minor free graphs. 2013. arXiv: 1304.5468.
  • Ken-ichi Kawarabayashi and Zi-Xia Song. Independence number and clique minors. J. Graph Theory, 56(3):219–226, 2007. doi: 10.1002/jgt.20268. MR: 2355127.
  • Alexandr V. Kostochka. The minimum Hadwiger number for graphs with a given mean degree of vertices. Metody Diskret. Analiz., 38:37–58, 1982. MR: 0713722, Zbl: 0544.05037.

Which BibTeX style can be used to obtain such thing? Which fields are used and how are they formatted?

How would I do this manually (without BibTeX)?

  • 4
    You should have a look at biblatex, which handles DOI and arXiv out of the box and should be easily extended to handle MR and Zbl as well. – You Dec 29 '13 at 11:04
  • 3
    This can be very easily done with biblatex: It already offers DOI and arXiv support and the other ones are easily added. There are also some BibTeX styles that support DOIs and that could probably be extended as well (see How to get DOI links in bibliography). If you insist on doing that manually - I don't think that is a a particularly good idea - you need to be a bit more specific about what you have in mind. It is certainly not very hard to write a doi macro (see the link above). – moewe Dec 29 '13 at 11:04
  • topic of interest: tex.stackexchange.com/questions/4972/… – pluton Mar 4 '14 at 15:30
6

biblatex is very good at things like this.

biblatex only allows for one eprint destination to be specified for each entry, so we will create a new field for each of the different e-print types.

We will have to ask biblatex to provide a verbatim field for that and enable it for all entry types.* This is done via a datamodel (.dbx) file. That file is created with filecontents in the example below, in practice you will probably not do that and just copy the .dbx file to a place TeX can find it.

We'll call the file ext-eprint.dbx

\ProvidesFile{ext-eprint.dbx}[2016/09/11 extended stand-alone eprint fields]
\DeclareDatamodelFields[type=field,datatype=verbatim]{arxiv,mr,zbl,jstor,hdl,pubmed,googlebooks,pmcid}
\DeclareDatamodelEntryfields{arxiv,mr,zbl,jstor,hdl,pubmed,googlebooks,pmcid}
\DeclareDatamodelFields[type=field,datatype=literal]{arxivclass}
\DeclareDatamodelEntryfields{arxivclass}

You then need to load the datamodel file. Assuming it is called ext-eprint.dbx, you pass the option datamodel=ext-eprint to biblatex at loading-time.

One can add arbitrary aliases via

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=pmid, fieldtarget=pubmed]
    }
  }
}

Then, of course, these e-prints need formats, the general pattern is quite similar

\makeatletter
\DeclareFieldFormat{arxiv}{%
  arXiv\addcolon\space
  \ifhyperref
    {\href{http://arxiv.org/\abx@arxivpath/#1}{%
       \nolinkurl{#1}%
       \iffieldundef{arxivclass}
         {}
         {\addspace\texttt{\mkbibbrackets{\thefield{arxivclass}}}}}}
    {\nolinkurl{#1}
     \iffieldundef{arxivclass}
       {}
       {\addspace\texttt{\mkbibbrackets{\thefield{arxivclass}}}}}}
\makeatother
\DeclareFieldFormat{pmcid}{%
  PMCID\addcolon\space
  \ifhyperref
    {\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{mr}{%
  MR\addcolon\space
  \ifhyperref
    {\href{http://www.ams.org/mathscinet-getitem?mr=MR#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{zbl}{%
  Zbl\addcolon\space
  \ifhyperref
    {\href{http://zbmath.org/?q=an:#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldAlias{jstor}{eprint:jstor}
\DeclareFieldAlias{hdl}{eprint:hdl}
\DeclareFieldAlias{pubmed}{eprint:pubmed}
\DeclareFieldAlias{googlebooks}{eprint:googlebooks}

biblatex uses the eprint bibmacro to print the eprint information, so we just add our new types there

\renewbibmacro*{eprint}{%
  \printfield{arxiv}%
  \newunit\newblock
  \printfield{jstor}%
  \newunit\newblock
  \printfield{mr}%
  \newunit\newblock
  \printfield{zbl}%
  \newunit\newblock
  \printfield{hdl}%
  \newunit\newblock
  \printfield{pubmed}%
  \newunit\newblock
  \printfield{pmcid}%
  \newunit\newblock
  \printfield{googlebooks}%
  \newunit\newblock
  \iffieldundef{eprinttype}
    {\printfield{eprint}}
    {\printfield[eprint:\strfield{eprinttype}]{eprint}}}

MWE

\documentclass[a4paper,12pt]{article}%
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}

\begin{filecontents*}{ext-eprint.dbx}
\ProvidesFile{ext-eprint.dbx}[2016/09/11 extended stand-alone eprint fields]
\DeclareDatamodelFields[type=field,datatype=verbatim]{arxiv,mr,zbl,jstor,hdl,pubmed,googlebooks,pmcid}
\DeclareDatamodelEntryfields{arxiv,mr,zbl,jstor,hdl,pubmed,googlebooks,pmcid}
\DeclareDatamodelFields[type=field,datatype=literal]{arxivclass}
\DeclareDatamodelEntryfields{arxivclass}
\end{filecontents*}

\begin{filecontents*}{\jobname.bib}
@article{ContEp,
  author        = {Mark G. Frei and Hitten P. Zaveri and Susan Arthurs and Gregory K. Bergey and Christophe Jouny and Klaus Lehnertz and Jean Gotman and Ivan Osorio and Theoden I. Netoff and Walter J. Freeman and John Jefferys and Gregory Worrell and Michel Le Van Quyen and Steven J. Schiff and Florian Mormannn},
  title         = {Controversies in epilepsy},
  subtitle      = {Debates held during the Fourth International Workshop on Seizure Prediction},
  journaltitle  = {Epilepsy \& Behavior},
  volume        = {19},
  number        = {1},
  pages         = {4-16},
  date          = {2010-09},
  doi           = {10.1016/j.yebeh.2010.06.009},
  pmcid         = {PMC2943379},
  pmid          = {20708976},
}
@article{frege,
  author        = {Gottlob Frege},
  title         = {The Thought},
  subtitle      = {A Logical Inquiry},
  journaltitle  = {Mind},
  series        = {newseries},
  volume        = {65},
  number        = {259},
  jstor         = {2251513},
  date          = {1956-07},
  pages         = {289-311},
}
@online{hawking,
  author      = {S. W. Hawking},
  title       = {Information Preservation and Weather Forecasting for Black Holes},
  arxiv       = {1401.5761},
  arxivclass  = {hep-th},
  date        = {2014-01-22},
}
@online{albar,
  author  = {B. Albar and D. Gon{\c c}alves},
  title   = {On triangles in $K_r$-minor free graphs},
  arxiv   = {1304.5468},
  year    = 2013,
}
@article{kawa,
  author    = {Ken-ichi Kawarabayashi and Zi-Xia Song},
  title     = {Independence number and clique minors},
  journal   = {J. Graph Theory},
  volume    = 56,
  number    = 3,
  pages     = {219-226},
  year      = 2007,
  doi       = {10.1002/jgt.20268},
  mr        = {2355127},
}

@article{kostochka,
  author    = {A. V. Kostochka},
  title     = {On the minimum of the Hadwiger number for graphs with given mean degree of vertices},
  journal   = {Metody Diskretn. Anal.},
  volume    = {38},
  pages     = {37--58},
  year      = {1982},
  mr        = {0713722},
  zbl       = {0544.05037},
}
\end{filecontents*}

\usepackage[backend=biber, style=authoryear-icomp, dashed=true, datamodel=ext-eprint]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=pmid, fieldtarget=pubmed]
    }
  }
}

\makeatletter
\DeclareFieldFormat{arxiv}{%
  arXiv\addcolon\space
  \ifhyperref
    {\href{http://arxiv.org/\abx@arxivpath/#1}{%
       \nolinkurl{#1}%
       \iffieldundef{arxivclass}
         {}
         {\addspace\texttt{\mkbibbrackets{\thefield{arxivclass}}}}}}
    {\nolinkurl{#1}
     \iffieldundef{arxivclass}
       {}
       {\addspace\texttt{\mkbibbrackets{\thefield{arxivclass}}}}}}
\makeatother
\DeclareFieldFormat{pmcid}{%
  PMCID\addcolon\space
  \ifhyperref
    {\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{mr}{%
  MR\addcolon\space
  \ifhyperref
    {\href{http://www.ams.org/mathscinet-getitem?mr=MR#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldFormat{zbl}{%
  Zbl\addcolon\space
  \ifhyperref
    {\href{http://zbmath.org/?q=an:#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\DeclareFieldAlias{jstor}{eprint:jstor}
\DeclareFieldAlias{hdl}{eprint:hdl}
\DeclareFieldAlias{pubmed}{eprint:pubmed}
\DeclareFieldAlias{googlebooks}{eprint:googlebooks}

\renewbibmacro*{eprint}{%
  \printfield{arxiv}%
  \newunit\newblock
  \printfield{jstor}%
  \newunit\newblock
  \printfield{mr}%
  \newunit\newblock
  \printfield{zbl}%
  \newunit\newblock
  \printfield{hdl}%
  \newunit\newblock
  \printfield{pubmed}%
  \newunit\newblock
  \printfield{pmcid}%
  \newunit\newblock
  \printfield{googlebooks}%
  \newunit\newblock
  \iffieldundef{eprinttype}
    {\printfield{eprint}}
    {\printfield[eprint:\strfield{eprinttype}]{eprint}}}


\begin{document}
  \nocite{baez/online,wassenberg,hawking,albar,kawa,kostochka,frege,ContEp}
  \printbibliography
\end{document}

enter image description here

* The biblatex documentation recommends to load \DeclareDatamodelFields and \DeclareDatamodelEntryfields in an external data model file, but it works in the document itself as well. See §4.5.3 Data Model Specification of the biblatex documentation. Starting with version 2.9, \DeclareDatamodel... commands must be externalised to an .dbx file. See Data model macro cannot be used in preamble.

  • I just tried your MWE above and things seem to be broken on the new biblatex/biber. In TeXLive 2016 it comes back with the ArXiv and DOI links, but not the others. Perhaps things have changed since biblatex now includes native support for ArXiV and JStor links. The codes does produce some warnings like "Package biblatex Warning: Data model macro 'DeclareDatamodelFields' cannot be u sed in preamble." – Paulo Ney Sep 11 '16 at 0:07
  • @PauloNey Please see Data model macro cannot be used in preamble. All \DeclareDatamodel... now need to go into an external .dbx file, the commends cannot be used in the preamble any more. Other than that the solution should still work fine. If you still have trouble getting the things to run even after reading the linked question, let me know or ask a new question. – moewe Sep 11 '16 at 5:39
  • Thanks! Everything worked as soon as I moved the declarations to the external .dbx file, but this is not very clear from the manual, and your answer is very helpful to probably a lot of people - so it deserves a rewrite. – Paulo Ney Sep 12 '16 at 17:58
  • @PauloNey §4.5.4 Data Model Specification has something about.dbx files. I have edited this answer here to refer to and use .dbx files. Let me know what you think. Is it clear enough? – moewe Sep 12 '16 at 19:20
  • Very nice! Full work solution! – Paulo Ney Sep 13 '16 at 21:38
3

These kinds of custom formatting changes are easily achievable with the recently developed Bibulous project (http://nzhagen.github.io/bibulous/). For the OP's example, we have a database file

@arxiv{one,
  author = {B. Albar and D. Gon{\c c}alves},
  title = "{On triangles in K\_r-minor free graphs}",
  eprint = {1304.5468},
  year = 2013
}

@article{two,
  author = {Ken-ichi Kawarabayashi and Zi-Xia Song},
  title = {Independence number and clique minors},
  journal = {J. Graph Theory},
  volume = 56,
  number = 3,
  pages = {219-226},
  year = 2007,
  doi = {10.1002/jgt.20268},
  mr = {2355127}
}

@article{three,
  author = {A. V. Kostochka},
  title = {On the minimum of the Hadwiger number for graphs with given mean degree of vertices},
  journal = {Metody Diskretn. Anal.},
  volume = {38},
  pages = {37--58},
  year = {1982},
  mr = {0713722},
  zbl = {0544.05037}
}

For these database entries, we can create a customized template that makes use of the zbl, mr, doi, and eprint fields as follows:

TEMPLATES:
arxiv = <au>. <title>. <year>. arXiv: \href{http://arxiv.org/abs/<eprint>}{<eprint>}.
article = <au>. <title>. <journal>, <volume>[(<number>)]:[<startpage>--<endpage>|<startpage>|<eid>|], <year>.[ doi: \href{http://dx.doi.org/<doi>}{<doi>}.][ MR: \href{http://www.ams.org/mathscinet-getitem?mr=MR<mr>}{<mr>}.][ Zbl: \href{http://zbmath.org/?q=an:<zbl>}{<zbl>}.]

Note that the above snippet is actually the complete style template file. Using the following LaTeX main file

\documentclass{article}
\usepackage[colorlinks=True,urlcolor=blue,citecolor=blue,breaklinks=true]{hyperref}

\begin{document}
\nocite{one,two,three}
\bibliographystyle{mybst}
\bibliography{mybib}
\end{document}

we get the formatted reference list requested by the OP:

enter image description here

  • 4
    The last messages on the developer mailing list were in 2006. I'm afraid the project is not developed any more. – egreg Mar 4 '14 at 13:55
  • From what I was able to find online about Bibulous online, I understand that it needs Python to be installed. (I do not have it installed on my computer.) If I understand your post correctly, mybib.bst is the BibTeX style which is generated by Bibulous. Could you please put somewhere this file, so that I can have a look at it? Should BibTeX or BibLaTeX be used for the resulting file? (Sorry for the newb question. I have not used BibLaTeX before.) Thanks in advance! – Martin Mar 5 '14 at 6:56
  • 1
    @Martin: Actually, the code snippet above that begins with the header "TEMPLATES:" is the entire mybib.bst file used for this example. The file format is only compatible with Bibulous and not with BibTeX or Biblatex. And, just to confirm, Bibulous does require Python, though installing Python is straightforward (<python.org/download/>). – nzh Mar 5 '14 at 12:41
  • 1
    @egreg: Perhaps there is confusion with the previous Bibulus project (notice Latin spelling rather than English). The Bibulous project mentioned here began with its first commit about a year ago and is still actively maintained. – nzh Mar 5 '14 at 12:43
  • @nzh Sorry, but I couldn't find Bibulous and there was no link, so I assumed wrongly you were talking of Bibulus. – egreg Mar 5 '14 at 12:51

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.