For a lecture note/book project I have to following problem: I have an extensive list of references processed by bibtex as usual, the entries coming from a large collection of bib-files. Now since the whole project is ment for students, I would like to add some recommendations for particular references like:

This is a standard text book where every student will have to take a look, for this course Chap~3 and Chap~4 are most important.

Of course, I can add lines like that directly as a "note" into the bib-files, but I do not want to spoil my bib-file collection with notes like that which I never will need again (imagine this kind of note appears in a journal article by accident).

So the question is: can I modify the behaviour of the bibitem command such that I have an additonal command like \bibnote{key}{text} somewhere in my main file, taking the key of the bibentry and adds some text at the end of it, maybe as a separate paragraph. Ideally, it would write things directly to the bbl-file automatically.

-
Make a back-up of your bib file? – percusse Feb 25 '13 at 8:55
@percuße hehe, sure that is one option. But the point is that I wanted the bibfiles to be kept sync with the master copy. Perhaps I will just do it this way though... – Stefan Waldmann Feb 25 '13 at 14:14

If the combination of biblatex+biber is an option you can use the mapping feature to add information to a bibentry. This can be done, by using

\DeclareSourcemap{
\maps{
\map{
\step[fieldset=entrykey, fieldvalue={<entryke>}]
\step[fieldset=note, fieldvalue={text for <entrykey>}]
}
}
}


and use a map for every reference for which you want to add the note.

Or an alternative is to introduce a new field, let us say, notesonlyformystudent (and use such a field in the .bib file).

\begin{filecontents}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal]{notesonlyformystudents}
\DeclareDatamodelEntryfields{notesonlyformystudents}
\end{filecontents}


and

\DeclareFieldFormat{notesonlyformystudents}{#1}
\renewbibmacro{finentry}{\finentry\par\printfield{notesonlyformystudents}}

-
Thanks, I was hoping to see a good old bibtex solution, but maybe this is now a good reason to switch to the 21st century ;) – Stefan Waldmann Feb 25 '13 at 14:16
@StefanWaldmann I have added a bibtex solution. – Guido Feb 25 '13 at 14:19

Here is a solution that does not require changing the style file. It uses the datatool package to collect the notes. Note also that there are versions for natbib and without natbib, choose what fits your demands.

\documentclass[a4paper,10pt]{article}
\usepackage{natbib}
\usepackage{datatool}
\usepackage{etoolbox}

%% database for personal temporary notes
\DTLnewdb{bibnotes}

%% command for notes
\def\bibnote#1#2{%
\DTLnewrow{bibnotes}
\DTLnewdbentry{bibnotes}{mylabel}{#1}
\DTLnewdbentry{bibnotes}{mynote}{#2}
}

%% patching the output
\makeatletter
\patchcmd{\@lbibitem}%
{\item[\hfil\NAT@anchor{#2}{\NAT@num}]}%
{%
\item[\hfil\NAT@anchor{#2}{\NAT@num}]%
\DTLforeach[\DTLiseq{\mylabel}{#2}]{bibnotes}{\mylabel=mylabel,\mynote=mynote}{\textit{\mynote}}
}{}{\message{^^JPatching failed^^J}}%

%% if natbib is not loaded
% \patchcmd{\@lbibitem}%
%   {\item[\@biblabel {#1}\hfill ]}%
%   {%
%     \item[\@biblabel {#1}\hfill ]%
%     \DTLforeach[\DTLiseq{\mylabel}{#2}]{bibnotes}{\mylabel=mylabel,\mynote=mynote}{\textit{\mynote}}
%   }{}{\message{^^JPatching failed^^J}}%
% \patchcmd{\@bibitem}%
%   {\item}%
%   {%
%     \item%
%     \DTLforeach[\DTLiseq{\mylabel}{#1}]{bibnotes}{\mylabel=mylabel,\mynote=mynote}{\textit{\mynote}}
%   }{}{\message{^^JPatching failed^^J}}%
\makeatother

\begin{document}

\cite{GhJaEn02,MeGa05,MuBeBoRo99}

\bibnote{GhJaEn02}{This is important }
\bibnote{GhJaEn02}{to understand chickens!}
\bibnote{MuBeBoRo99}{Cheese!}

\bibliographystyle{plainnat}
\bibliography{test}
\end{document}


-

Here is a solution that can be used in conjunction with biblatex and bibtex

\makeatletter
\newcommand{\bibnote}[2]{\@namedef{#1note}{#2}}
\makeatother


For biblatex one has to redefine the finentry biblatex macro

\renewbibmacro{finentry}{\finentry\par\csname \thefield{entrykey}note\endcsname\finentry}


For bibtex one has to modify the .bst bibliographic style, in particular, redefine the fin.entry function as follows:

FUNCTION {fin.entry}
{ add.period$write$
newline$"\par\csname " write$
cite$write$
"note\endcsname" write$newline$
}

-