[Tex/LaTex] Why does the nature biblatex style not always show the DOI and URL

biblatex

I am using biblatex with the biblatex-nature package for my bibliography, and I've come across a peculiarity where the DOI and URL fields are not shown when the bibliographic entry includes the page numbers. I tried natbib with the nature package to see whether the behaviour was the same, but, in that case, the DOI and URL entries are typeset.

Surely that can't be the right behaviour, can it? Either way, whether this is the intended behaviour, how can I get the biblatex-nature package to always show the DOI and URL? Forcing the DOI and URL fields to be shown with doi=true and url=true does not help. The only way I found to get a:agrawal:2001:01 to show the URL and DOI is by removing the pages field.

MWE:

\documentclass{article}

\begin{filecontents*}{bib.bib}
@Article{a:agrawal:2001:01,
  title         = {Phenotypic Plasticity in the Interactions and Evolution of Species},
  author        = {Agrawal, Anurag A.},
  journal       = {Science},
  year          = {2001},
  month         = oct,
  volume        = {294},
  number        = {5541},
  pages         = {321--326},
  doi           = {10.1126/science.1060701},
  url           = {http://dx.doi.org/10.1126/science.1060701},
}

@Article{a:brown:2013:01,
  title         = {What Evolvability Really Is},
  author        = {Brown, Rachael L.},
  journal       = {The British Journal for the Philosophy of Science},
  year          = {2013},
  month         = aug,
  doi           = {10.1093/bjps/axt014},
  url           = {http://dx.doi.org/10.1093/bjps/axt014},
}
\end{filecontents*}

% \usepackage[numbers]{natbib} % Uncomment for natbib.
\usepackage[backend=biber,style=nature]{biblatex}
\addbibresource{bib.bib}

\begin{document}
\noindent\parencite{a:agrawal:2001:01} \\
\parencite{a:brown:2013:01}

% Uncomment for natbib.
% \bibliographystyle{naturemag}
% \bibliography{bib}

\printbibliography
\end{document}

Output

Best Answer

The behaviour here is set up in the main article driver:

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \iftoggle{bbx:articletitle}
    {%
      \usebibmacro{title}%
      \newblock
    }
    {}%
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \iffieldundef{pages}% KEY PART HERE
    {\usebibmacro{doi+eprint+url}}
    {}%
  \setunit{\addspace}\newblock
  \usebibmacro{issue+date}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \usebibmacro{related}%
  \usebibmacro{finentry}%
}

Thus the easiest change is to simply redefine the driver

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \iftoggle{bbx:articletitle}
    {%
      \usebibmacro{title}%
      \newblock
    }
    {}%
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \setunit{\addspace}\newblock
  \usebibmacro{issue+date}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \usebibmacro{related}%
  \usebibmacro{finentry}%
}

(You can do this using patching approaches if you prefer.)