2

I would like to modify the MWE presented in

Biblatex and Pubmed/Pubmed Central IDs

The working example presented there works perfectly, but now I'd like to modify it to work with a BibDesk-generated file where Pmc is used for the PubMedCentral ID field, and Pmid is used for the PubMed ID field. So I modified the MWE by replacing pmcid with Pmc and pmid with Pmid, but it does not work in that now neither the PMCID nor the PMID parts appear in the typeset PDF (see code below) - any suggestions?

\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},
  Pmc         = {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]{Pmc}
\DeclareDatamodelEntryfields{Pmc}
\end{filecontents*}

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

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \newunit\newblock
  \printfield{Pmc}%
  \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}

Alternatively, is there a way to instruct BibDesk to use pmcid and pmid field labels when importing from PubMed?

0
3

While the BibTeX/.bib-file side of things is not case sensitive, the LaTeX side of things is (because TeX is case sensitive).

In practice that means that in your .bib file you can write Pmid, pmid, PMID or pMiD and they all mean the same thing, but in your .tex file and in biblatex configurations those four strings are not the same. The biblatex side of things assumes that all field names (and also entry types) are in lowercase (if in doubt, assuming that internal biblatex names use lowercase only is a good guess).

So you must write \printfield{pmc}% and also \DeclareDatamodelEntryfields{pmid}, etc. etc.

The following example works for me.

\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},
  Pmc           = {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]{pmc}
\DeclareDatamodelEntryfields{pmc}
\end{filecontents*}

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

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \newunit\newblock
  \printfield{pmc}%
  \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}

Frei, Mark G. et al. (Sept. 2010). “Controversies in epilepsy. Debates held during the Fourth International Workshop on Seizure Prediction”. In: Epilepsy & Behavior 19.1, pp. 4–16. doi: 10.1016/j.yebeh.2010.06.009. PMCID: PMC2943379. PMID: 20708976.

Note that the capitalisation of the eprint:... field formats is different from the capitalisation of proper fields. That is because the eprint field formats rely not only on the internal name of the field (eprint), but also on the content of the eprinttype field (which is case sensitive, hence eprint:PMC and eprint:pmc are different).

In your setup most eprint formats are not needed, so

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

\DeclareFieldAlias{pmid}{eprint:pubmed}

should be enough and might be clearer as to what is going on.

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.