I'm using the verbose bibliography style in biblatex, and would like to place the URL and DOI fields at the end of each entry, after the (cited on page …) field rather than before it. Is there a way to reorder the fields of an existing style?
Biblatex – Can Fields Be Reordered in a Biblatex Bibliography?
biblatex
Related Solutions
If biber
is used as backend, then one can use the \DeclareSourcemap
facilities to change fields.
For the case at hand a solution is to remap url
entries with dx.doi.org
as initial part using the following code:
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[ % copies url to doi field if it starts with http://dx.doi.org/
fieldsource=url,
match=\regexp{http://dx.doi.org/(.+)},
fieldtarget=doi,
]
\step[ % removes http://dx.doi.org/ string from doi field
fieldsource=doi,
match=\regexp{http://dx.doi.org/(.+)},
replace=\regexp{$1}
]
}
\map{ % removes url + urldate field from all entries that have a doi field
\step[fieldsource=doi, final]
\step[fieldset=url, null]
\step[fieldset=urldate, null]
}
}
}
The actual value inside \regexp
can be adjusted.
In the first step we create a doi
field for each entry where the url
field matches the regexp, and the novel field has the value of the url
field. In the second step we remove the doi "namespace".
In the second \map
sequence the url and urldate fields are cleared if a doi field is present, to mimic the behavior in the first part of the original question.
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.)
Best Answer
For the general case, when the fields you're wanting to reorder don't necessarily appear at the end, biblatex's
\clearfield
-type macros and the xpatch package come in handy.