This is a follow up to Adding information to bibitems in which \@lbibitem
is tweaked to allow the addition of text before the BibTeX entry. This works fine, however I want to be able to add text before and after an entry, e.g. to add a (*
) at the beginning to indicate required reading and some text after the entry to indicate specific section
s or bookchapters:
*William Easterly. Can the west save Africa? Journal of Economic Literature, pages 373–447, 2009. Please read sections 2-4
Here is a slightly adapted minimum example from the answer linked above:
\documentclass[a4paper,10pt]{article}
\usepackage[round]{natbib}
\usepackage{datatool}
\usepackage{etoolbox}
%% database for personal temporary notes
\DTLnewdb{bibnotes}
%% command for pre notes
\def\bibpre#1#2{%
\DTLnewrow{bibnotes}
\DTLnewdbentry{bibnotes}{pre}{#1}
\DTLnewdbentry{bibnotes}{mynote}{#2}
}
% command for post notes
\def\bibpost#1#2{%
\DTLnewrow{bibnotes}
\DTLnewdbentry{bibnotes}{post}{#1}
\DTLnewdbentry{bibnotes}{mynote}{#2}
}
%% patching the output
\makeatletter
%% if natbib is loaded
%% this does not work as intended as notes are always placed before the bib entry
\patchcmd{\@lbibitem}%
{\item[\hfil\NAT@anchor{#2}{\NAT@num}]}%
{%
\item[\NAT@anchor{#2}{\NAT@num}\hfil]%
\DTLforeach[\DTLiseq{\pre}{#2}]{bibnotes}{\pre=pre,\mynote=mynote}{\mynote}%
\DTLforeach[\DTLiseq{\post}{#2}]{bibnotes}{\post=post,\mynote=mynote}{\mynote}%
}{}{\message{^^JPatching failed^^J}}%
% \apptocmd{\@lbibitem}%
% {\DTLforeach[\DTLiseq{\post}{#2}]{bibnotes}{\post=post,\mynote=mynote}{\mynote}}
% {}{\message{^^Japptocmd failed^^J}}%
\makeatother
\begin{document}
\citet{easterly2009can,frankel1999does}
%% comments to be displayed before/after bibtex entry
\bibpre{easterly2009can}{*}
\bibpost{frankel1999does}{please read ch.\ 4}
\bibpre{frankel1999does}{*}
\bibliographystyle{plainnat}
\bibliography{bib}
\end{document}
The bib.bib
file I used is
@Article{ easterly2009can,
Author = "William Easterly",
Title = "Can the West Save Africa?",
Journal = "Journal of Economic Literature",
Pages = "373--447",
year = 2009
}
@Article{ frankel1999does,
Author = "J.A. Frankel and D. Romer",
Title = "Does trade cause growth?",
Journal = "American Economic Review",
Pages = "379--399",
year = 1999
}
This results in
References
*William Easterly. Can the west save africa? Journal of Economic Literature,
pages 373–447, 2009.*please read ch. 4J.A. Frankel and D. Romer. Does trade cause growth? Amer-
ican Economic Review, pages 379–399, 1999.
I found that changing the order of commands in \patchcmd{\@lbibitem}
gives an error message and \apptocmd{\@lbibitem}
also adds notes before the bib entry, not after.
Best Answer
Have you try biblatex? Biblatex is a complete reimplementation of the bibliographic facilities provided by LaTeX in conjunction with BibTeX.
With biblatex isn't that hard to add pre and post annotations to entries. Like this:
If you want to add the same annotations but in your
.bib file
you should do something like this:with this
bib.bib
:However, I couldn't find how to reorder the block entities in each bibtex entry. May be you have more luck.
I should remark that citation and bibliographic styles may be changed. Check biblatex documentation for this. Here is a question for customizing biblatex styles.
Following the question: How to cite all bib entries that have no annotations in a simple way? (making minor changes to the
.bib
file that not affect normal use of the file)with this
biblLong.bib
: