Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 13 down vote accepted

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[colorlinks]{hyperref}
\usepackage{xpatch}

\newbibmacro*{addendum+pubstate+pageref}{%
  \usebibmacro{addendum+pubstate}%
  \clearfield{addendum}%
  \clearfield{pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \clearlist{pageref}%
  \newunit\newblock}

\xpretobibmacro{doi+eprint+url}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{eprint}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{url+urldate}{\usebibmacro{addendum+pubstate+pageref}}{}{}

\addbibresource{biblatex-examples.bib}

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

enter image description here

share|improve this answer
    
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
2  
@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
2  
@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
show 2 more comments

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
  \usebibmacro{addendum+pubstate}%
  \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}

\addbibresource{\jobname.bib}

\begin{document}

Some text \autocite{A01}.

\printbibliography

\end{document}

enter image description here

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
  \usebibmacro{addendum+pubstate}%
  \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
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \usebibmacro{finentry}}
share|improve this answer
    
Sneaky, but clever. –  Alan Munn Mar 4 '12 at 22:32
    
Excellent, this mostly works, but I get odd behavior: some entries end up with two URLs, one before and one after the "cited on" field. I'm trying to generate a MWE to reproduce the behavior, but it's erratic. Changing citations around, causes the effected entry to change. –  raxacoricofallapatorius Mar 4 '12 at 22:35
1  
@raxacoricofallapatorius See edited answer. –  lockstep Mar 4 '12 at 22:42
    
Ick. Works great though, thanks! –  raxacoricofallapatorius Mar 4 '12 at 22:45
1  
@lockstep The eprint bibliography macro has the same issue. –  Audrey Mar 4 '12 at 22:53
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.