Skip to main content
blog

Creating a bibliography with links to PubMed and PubMedCentral

By February 24, 2020No Comments

We just submitted a paper to Nucleic Acids Research Web Server issue. As it

turns out, the editor requires a bibliography with links to DOI, PubMed, and PubMedCentral entries.

This is a brief tutorial to generate such a bibliography from a bibtex file

which contains the relevant entries, loosely based on the explanations

provided in this TeX StackExchange entry.

Generating the bibtex file

In the lab, we mainly use Paperpile as bibliography management system, but most system allow to export records in bibtex format. If available, Paperpile includes DOI, PubMed IDs, and PubMedCentral IDs as follows:

@ARTICLE{Glover2019-xs, 

    title    = "{Assigning confidence scores to homoeologs using fuzzy logic}",  

    author   = "Glover, Natasha M and Altenhoff, Adrian and Dessimoz, Christophe",

    journal  = "PeerJ",

    volume   =  6,

    pages    = "e6231",

    year     =  2019,

    doi      = "10.7717/peerj.6231",

    pmid     = "30648004",

    pmc      = "PMC6330999"

}

In this example, we store the bibliography in a file named ref.bib.

Extending biblatex to include PMID and PMC links in the bibliography

DOI are already supported by most bibliography systems. To also include PMID and PMCIDs, the trick is to use the flexible BibLatex package.

In a separate definition file, which we named adn.dbx, add the

additional definitions for PMID and PMCIDs.

DeclareDatamodelFields[type=field,datatype=literal]{

    pmid,

    pmc,

}

We can now include this file in the library definition in the main LaTeX file

(in the preamble, i.e. before begin{document}, and define the

links to PubMed and PubMedCentral entries:

usepackage[backend=biber,style=authoryear,datamodel=adn]{biblatex}

DeclareFieldFormat{pmc}{%

  PubMedCentraladdcolonspace

  ifhyperref

    {href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{nolinkurl{#1}}}

    {nolinkurl{#1}}}

DeclareFieldFormat{pmid}{%

  PubMed ID:addcolonspace

  ifhyperref

    {href{https://www.ncbi.nlm.nih.gov/pubmed/#1}{nolinkurl{#1}}}

    {nolinkurl{#1}}}

renewbibmacro*{finentry}{%

  printfield{pmid}%

  newunit

  printfield{pmc}%

  newunit

  finentry}

addbibresource{ref.bib}

We can generate the bibliography by citing every paper using the cite{} command, and printing the bibliography.

cite{Glover2019-xs}

newpage

printbibliography

Polishing: highlighting the links with colour

To make the links more visible, define the hyperref package

accordingly:


usepackage[colorlinks]{hyperref}

OK, thanks but could I just have the files please?

Of course! Here they are.