13

I am using an additional bibliography inside my thesis. This includes only articles to which I contributed. Displaying these works fine, but I would like to add some comment before each cited paper. My code so far looks like this:

\documentclass{scrreprt}
\usepackage[bibstyle=authoryear, backend=bibtex8]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{jobname.bib}
@misc{A2011,
  author = {Author, A.},
  year = {2011},
  title = {A short title.},      
}
@misc{A2012,
  author = {Buthor, B.},
  year = {2012},
  title = {Systems biology and personalized medicine are two emerging research areas, which promise to transform our health system.},
}
@misc{A2013,
  author = {Cuthor, C.},
  year = {2013},
  title = {This title is not so short.},
}
\end{filecontents}
\addbibresource{jobname.bib}

\begin{document}
\defbibnote{myprenote}{This thesis is based on the following original publications:}
\nocite{A2012, A2013}
\printbibliography[prenote=myprenote,title={List of original publications}]
\end{document}

This adds paper 2 and 3 to the bibliography, but I cannot enter a comment above it. I made a short visualization what I am trying to get:

enter image description here

This piece of code from this tex.sx article adds a comment to the bibliography.

\DeclareDatamodelFields[type=field,datatype=literal]{mynote}
\usepackage{xpatch}
\xapptobibmacro{finentry}{\par\printfield{mynote}}{}{}

But how can I add the commment before the entry (as indicated by the arrows in the image above)?

  • Should the text appear at the beginning just after the title "Bibliography", or do you want to be able to insert text in arbitrary positions, between some entries? – Gonzalo Medina Feb 11 '14 at 12:25
  • @GonzaloMedina I would like to add the text after the myprenote text and directly before the reference. So basically free positioned, I have added a picture above to make it clearer. – Chris Feb 11 '14 at 12:56
  • possible duplicate of How to comment references in a bibliography – StrongBad Feb 11 '14 at 13:49
  • 2
    This is not a duplicate! This one wants a comment as well, but at a diffent place! – yo' Feb 11 '14 at 14:48
  • @tohecz but the answer is more or less identical. – StrongBad Feb 11 '14 at 15:30
7

There are two issues with adding a "note" before every item. The first issue is getting the "note" and the second issue is printing the note.

Using the bibtex8 backend for biblatex constrains the fields that can be used in your bib file. For this application, you would probably want to use the note field, although this will cause problems for any entries that need the note field to carry extra information. If you can use biber as the backend then you can define your own fields and data model.

\DeclareDatamodelFields[type=field,datatype=literal]{mynote}

and then you do not have to worry about clashes.

Printing the note before the entry is easier than after the entry since there is the \AtEveryBibitem hook. The only trick is that the bibliography is in a list environment so you need an \item and not a \par after the note. You also need to clear the note field so it is not used later. You can add the note with

\AtEveryBibitem{\printfield{note}\clearfield{note}\item}

A full MWE

\documentclass{scrreprt}
\usepackage[bibstyle=authoryear, backend=bibtex8]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A2011,
  author = {Author, A.},
  year = {2011},
  title = {A short title.},      
  note = {This source is really interesting because it doesn't have a real title}
}
@misc{A2012,
  author = {Buthor, B.},
  year = {2012},
  title = {Systems biology and personalized medicine are two emerging research areas, which promise to transform our health system.},
  note = {This second source is also really interesting because it contains words}
}
@misc{A2013,
  author = {Cuthor, C.},
  year = {2013},
  title = {This title is not so short.},
  note = {This third source is not interesting}
}
\end{filecontents}
\addbibresource{\jobname.bib}


\AtEveryBibitem{\printfield{note}\clearfield{note}\item}
\begin{document}
\defbibnote{myprenote}{This thesis is based on the following original publications:}
\nocite{A2012, A2013}
\printbibliography[prenote=myprenote,title={List of original publications}]
\end{document}

enter image description here

| improve this answer | |
  • I don't use the note field, so this would work. At the moment the note also appears in the reference, can it be suppressed there selectively? – Chris Feb 11 '14 at 16:13
  • @Chris oppps, I missed that. I fixed it. – StrongBad Feb 11 '14 at 16:26
  • This works perfect, thanks. I am currently not using Biber since it doesn't work and I have to find out why. But this is a project on my list, once I have turned my thesis. At the moment I am not changing any packets. – Chris Feb 11 '14 at 17:00
  • One additional question: Can this be different when more than one bibliography is used (meaning one bibliography displays the notes as described above and another one suppresses them completely)? – Chris Feb 11 '14 at 17:09
  • @Chris this seems like something that may have been asked before. If not, you should probably ask it as a new question with an MWE. – StrongBad Feb 11 '14 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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