# Can I reorder the fields in a biblatex bibliography?

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?

-

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.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=verbose,backref=true]{biblatex}
\usepackage{xpatch}

\clearfield{pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\clearlist{pageref}%
\newunit\newblock}

\begin{document}
\null\vfill\noindent
Filler text.\footcite{bertram,kastenholz,ctan,itzhaki}
\printbibliography
\end{document}


-
I'm out of votes for today, but will upvote tomorrow. – lockstep Mar 4 '12 at 23:32
@lockstep No worries. You did all the upfront work. I just wanted to post another way, which is in fact only possible because of your previous question about patching bibliography macros... – Audrey Mar 4 '12 at 23:37
Let's hope that biblatex v2/v3 provides a user-friendly interface for this sort of customizations. – lockstep Mar 4 '12 at 23:39
@raxacoricofallapatorius From another one of your questions it looks like you want linebreaks before URLs and URLs only in the bibliography. You can do the first part easily by replacing \newunit\newblock with \setunit{\adddot\par\nobreak}. You can follow Marco's advice and edit the URL formats for the second part, but you could also use \AtEveryCitekey{\clearfield{url}\clearfield{doi}\clearfield{eprint}}. – Audrey Mar 5 '12 at 0:25
@raxacoricofallapatorius The URL prefixes are generated by the field format, so you'll have to edit those. For example, take format definition from biblatex.def: \DeclareFieldFormat{url}{\mkbibacro{URL}\addcolon\space\url{#1}}. You'll want to change this to \DeclareFieldFormat{url}{\url{#1}}. If you need help with the other fields, just post a new question. – Audrey Mar 5 '12 at 1:12

In the bibliography styles shipped with biblatex, the drivers for the different entry types (@article, @book, ...) typically end with

  \newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}


So one may redefine the doi+eprint+url bibmacro to do nothing, while the finentry bibmacro also undertakes the tasks of the original doi+eprint+url (instead of only typesetting a \finentrypoint).

\documentclass{article}

\usepackage[style=verbose,backref=true]{biblatex}

\renewbibmacro*{doi+eprint+url}{}

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

\textheight=120pt% just for the example

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
url = {www.tex.stackechange.com},
}
\end{filecontents}

\begin{document}

Some text \autocite{A01}.

\printbibliography

\end{document}


Note: The drivers for the @online and @unpublished entry types directly use the url+urdate bibmacro. You can't redefine this macro to do nothing because it is used internally by doi+eprint+url. Instead, you have to copy the definition of @online and @unpublished to your document preamble and remove the respective code lines.

\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\newunit\newblock
\usebibmacro{date}%
%   \newunit\newblock% DELETED
%   \iftoggle{bbx:eprint}% DELETED
%     {\usebibmacro{eprint}}% DELETED
%     {}% DELETED
%   \newunit\newblock% DELETED
%   \usebibmacro{url+urldate}% DELETED
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}

\DeclareBibliographyDriver{unpublished}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{location+date}%
%   \newunit\newblock% DELETED
%   \iftoggle{bbx:url}% DELETED
%     {\usebibmacro{url+urldate}}% DELETED
%     {}% DELETED
\newunit\newblock

@lockstep The eprint bibliography macro has the same issue. – Audrey Mar 4 '12 at 22:53