# Biblatex and Pubmed/Pubmed Central IDs

As a biomedical scientist learning more and more about latex I was pleased to read of support for the typesetting of Pubmed IDs (PMID) by biblatex as outlined on page 141 of the biblatex manual.

However entries to Pubmed as outlined on page 141 are not links to eprints, but links to primarily an abstract for the paper, as well as links to the full text of the paper primarily via a doi.

There is a separate database called Pubmed Central which contains links to free full-text, which requires a separate number called a PMCID.

For example, http://www.ncbi.nlm.nih.gov/pubmed/20708976 is a link to a Pubmed abstract. Here the appropriate designation is PMID: 20708976. Associated with this abstract is a link with free full text in Pubmed Central http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2943379/ which truly is an eprint, and where the appropriate designation is PMCID: PMC2943379

How can I instruct biblatex to print either the PMID, or both the PMID and the PMCID for my papers in the same fashion as outline in the biblatex manual, perhaps alongside a DOI and/or a URL? Could this perhaps be reflected in the next edition of the biblatex manual?

(A way to think of this for those mathematically minded is thinking of Pubmed like MathSciNet, and Pubmed Central like the arxiv. A MR number doesn't mean it is an eprint nor does a PMID—this is where the biblatex manual confused me).

## 1 Answer

In biblatex you unfortunately (?) cannot have two eprinttypes for the same entry, it will take some trickery to do that.

But to go only with the PMCID is a piece of cake. Add the following lines to your preamble

\DeclareFieldFormat{eprint:pmcid}{%
PMCID\addcolon\space
\ifhyperref
{\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:PMCID}{eprint:pmcid}
\DeclareFieldAlias{eprint:pmc}{eprint:pmcid}


This will tell biblatex what to do with eprinttype = {pmcid}s.

A sample entry looks like this

@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},
eprint         = {PMC2943379},
eprinttype    = {pmcid},
}


Note that there is no problem at all to also display DOI and URL.

\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}
\usepackage{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},
%eprint        = {20708976},
%eprinttype    = {pubmed},
eprint         = {PMC2943379},
eprinttype    = {pmcid},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\DeclareFieldFormat{eprint:pmcid}{%
PMCID\addcolon\space
\ifhyperref
{\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:PMC}{eprint:pmcid}
\DeclareFieldAlias{eprint:PMCID}{eprint:pmcid}
\DeclareFieldAlias{eprint:pmc}{eprint:pmcid}

\begin{document}
\cite{ContEp}
\printbibliography
\end{document}


You could also set up fields for pmid and pmcid so they do not take up the eprint slot and can be used side-by-side.

We will need a datamodel for that (here we use biblatex-dm.cfg; the file should be put somewhere LaTeX can find it; in the MWE the file is automatically created via the filecontents environment; read more about datamodel files on page 151 of the biblatex documentation §4.5.3 Data Model Specification). You could also create a dedicated datamodel file (.dbx) and load that, see Data model macro cannot be used in preamble, BibTeX fields for DOI, MR, Zbl and arxiv?, How can I create entirely new data types with BibLaTeX/Biber? for explanations and examples of .dbx files.

\DeclareDatamodelFields[type=field,datatype=verbatim]{pmid}
\DeclareDatamodelEntryfields{pmid}
\DeclareDatamodelFields[type=field,datatype=verbatim]{pmcid}
\DeclareDatamodelEntryfields{pmcid}


So now we have the fields pmid and pmcid available for use.

We need to declare their formatting to print these fields (we just do this as we did above).

\DeclareFieldFormat{eprint:pmcid}{%
PMCID\addcolon\space
\ifhyperref
{\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:PMC}{eprint:pmcid}
\DeclareFieldAlias{eprint:PMCID}{eprint:pmcid}
\DeclareFieldAlias{eprint:pmc}{eprint:pmcid}
\DeclareFieldAlias{pmcid}{eprint:pmcid}
\DeclareFieldAlias{pmid}{eprint:pubmed}


Furthermore, we need to print the fields, this is achieved by redefining the doi+eprint+url macro.

\renewbibmacro*{doi+eprint+url}{%
\iftoggle{bbx:doi}
{\printfield{doi}}
{}%
\newunit\newblock
\printfield{pmcid}%
\newunit\newblock
\printfield{pmid}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}}


Note that now, the sample entry looks like this

@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},
}


The MWE

\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}
\usepackage{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},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

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

\DeclareFieldFormat{eprint:pmcid}{%
PMCID\addcolon\space
\ifhyperref
{\href{http://www.ncbi.nlm.nih.gov/pmc/articles/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:PMC}{eprint:pmcid}
\DeclareFieldAlias{eprint:PMCID}{eprint:pmcid}
\DeclareFieldAlias{eprint:pmc}{eprint:pmcid}
\DeclareFieldAlias{pmcid}{eprint:pmcid}
\DeclareFieldAlias{pmid}{eprint:pubmed}

\renewbibmacro*{doi+eprint+url}{%
\iftoggle{bbx:doi}
{\printfield{doi}}
{}%
\newunit\newblock
\printfield{pmcid}%
\newunit\newblock
\printfield{pmid}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}}

\begin{document}
\cite{ContEp}
\printbibliography
\end{document}


• Works pretty good and I could easily adjust it to my own needs. Thanks. Jun 3 '16 at 15:05
• @moewe Same as your other solution tex.stackexchange.com/questions/151628/… this one also seems to have stopped working with the new release of Biblatex/Biber on TeXLive 2016. Sep 11 '16 at 1:33
• @PauloNey Just for completeness: Data model macro cannot be used in preamble. (Cf. also my longer comment under the other answer.) Sep 11 '16 at 5:40
• @PauloNey I just checked this solution and since it uses biblatex-dm.cfg it works just fine. I have updated the other answer. Sep 11 '16 at 7:00