20

I've been playing around with biblatex a little and, since I am tired of broken DOIs, URLS and other eprint links, I would like to use a biblatex style which implements a new line for these fields. I started from the standard.bbx file and in the article style, I replaced

\newunit\newblock
\usebibmacro{doi+eprint+url}

by

\newline
\usebibmacro{doi+eprint+url}

There is something wrong since a dot (.) is added at the beginning of the DOI line in the final bibliography and a new line is added even though the doi field is empty. Is there a way to fix this?

Then, I wanted to go a bit further by having a new line for each of the DOI, URL, EPRINT, then something like:

\newline
\usebibmacro{doi}
\newline
\usebibmacro{url}
\newline
\usebibmacro{eprint}

by replacing \newbibmacro*{doi+eprint+url} by \newbibmacro*{doi}, \newbibmacro*{eprint} and \newbibmacro*{url} (copy-paste process of the last lines of standard.bbx) and by replacing \usebibmacro{doi+eprint+url} by the lines above but unfortunately, it does not work. I'd be happy to hear from you on this.

1

2 Answers 2

23

\setunit is an alternative to \newunit that allows you to set punctuation instead of \newunitpunct (which is typically a period plus a space). The really neat thing about \newunit and \setunit is that you don't need to worry about generating excessive punctuation, particularly when some fields are missing.

The code below defines a new bibliography macro bbx:parunit. It issues \setunit to generate line breaks only in the bibliography. With the option setting backref=true, bbx:parunit also prints the back reference immediately before the first line break. Edits are applied to generic bibliography macros from biblatex.def so that the solution should work with most styles.

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

\newbibmacro*{bbx:parunit}{%
  \ifbibliography
    {\setunit{\bibpagerefpunct}\newblock
     \usebibmacro{pageref}%
     \clearlist{pageref}%
     \setunit{\adddot\par\nobreak}}
    {}}

\renewbibmacro*{doi+eprint+url}{%
  \usebibmacro{bbx:parunit}% Added
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}}

\renewbibmacro*{eprint}{%
  \usebibmacro{bbx:parunit}% Added
  \iffieldundef{eprinttype}
    {\printfield{eprint}}
    {\printfield[eprint:\strfield{eprinttype}]{eprint}}}

\renewbibmacro*{url+urldate}{%
  \usebibmacro{bbx:parunit}% Added
  \printfield{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \printtext[urldate]{\printurldate}}}

\addbibresource{biblatex-examples.bib}

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

enter image description here

12
  • That's very nice but now, \footcite is a bit too long. I think that \footcite with the author, the year and the title + a numeric link to the full biblio at the end of the document (the way numeric style works now but the link [1] would be embedded in the \footcite) would be the best compromise.
    – pluton
    Sep 28, 2011 at 22:20
  • Nice again and clearly usable. You think it is possible to control/reduce what is in the footnotes by keeping what is in the main references? Something like: Initials and family names for the authors; title; year; journal and no more? That'd be great !
    – pluton
    Sep 28, 2011 at 23:33
  • @pluton It is definitely possible, but I'd open that up as a new question as that problem is very style-specific and separate from your original question.
    – Audrey
    Sep 28, 2011 at 23:39
  • I do not know now since your solution is very nice. I was thinking of the usual style=numeric and \footcite{ref1} (your first reference) would provide as a footnote : A. Bertram & R. Wentworth, "Gromov invariants for holomorphic maps on Riemann surfaces", J. Amer. Math. Soc (1996) [1] and the [1] would be linked to the full citation at the end organised by the usual numeric style, but that's just an idea.
    – pluton
    Sep 28, 2011 at 23:41
  • about your very last comment, I'll open a new question as soon as possible. Many thanks!
    – pluton
    Sep 28, 2011 at 23:44
9

You can't directly include \newline in the .bbx file as it is 'text' and will be out of position in the biblatex tracker. Instead, you need to use the \printtext macro

\printtext{\newline}%
\usebibmacro{doi}%
\printtext{\newline}%
\usebibmacro{url}%
\printtext{\newline}%
\usebibmacro{eprint}%

I'd probably make this a bit more sophisticated, and use \iffieldundef to conditionally include these new lines

\iffieldundef{doi}
  {}
  {%
    \printtext{\newline}%
    \usebibmacro{doi}%
  }%
3
  • Thanks. Sounds promising. And the {doi+eprint+url} environment could be redefined separately as \newbibmacro*{doi}{\iftoggle{bbx:doi}{\printfield{doi}}{}} plus the same for eprint and url?
    – pluton
    Sep 28, 2011 at 17:15
  • I am not sure why Audrey removed the provided answer?
    – pluton
    Sep 28, 2011 at 17:22
  • @pluton It had bug I wanted to fix. The post is back now.
    – Audrey
    Sep 28, 2011 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .