这是向 bibitems 添加信息在其中\@lbibitem
进行了调整,允许在 BibTeX 条目前添加文本。这很好,但是我希望能够在和在条目之后,例如*
在开头添加 ( ) 来表示必读内容,并在条目后添加一些文本来表示特定的section
书或章节:
*威廉·伊斯特利。《西方能拯救非洲吗?》《经济文献杂志》,第 373-447 页,2009 年。请阅读第 2-4 节
以下是根据上面链接的答案稍微改编的最小示例:
\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}
我使用的文件bib.bib
是
@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
}
这导致
参考
*William Easterly。西方能拯救非洲吗?《经济文献杂志》,第 373-447 页,2009 年。
*请阅读第 4 章 J.A. Frankel 和 D. Romer。贸易导致增长吗?《美国经济评论》,第 379-399 页,1999 年。
我发现改变命令的顺序\patchcmd{\@lbibitem}
会出现错误消息,并且\apptocmd{\@lbibitem}
会在 bib 条目之前添加注释,而不是之后。
答案1
你试过吗比布拉特克斯? Biblatex 是 LaTeX 与 BibTeX 结合提供的书目设施的完整重新实现。
使用 biblatex 为条目添加前后注释并不难。像这样:
\documentclass[a4paper,10pt]{article}
\usepackage[natbib, % To use natbib commands
style=authoryear, % Style of cites and bib entries
backend=bibtex8] % To use bibtex instead biber
{biblatex}
\addbibresource{bib.bib} % Loading .bib file
\renewbibmacro{in:}{% % To remove "In:" from articles
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}
\DefineBibliographyStrings{english}{pages={pages}} % To change default pp.
\DefineBibliographyStrings{english}{page={page}} % To change default p.
\begin{document}
\citet{easterly2009can,frankel1999does} % Cite as if you were using natbib
\section*{References}
% use \fullcite[prenote][posnote]{bibentrylabel}
\noindent \fullcite[*][Please read sections 32-33]{easterly2009can} \\
\noindent \fullcite[*][Please read sections 2-4]{frankel1999does} \end{document}
如果您想添加相同的注释,但.bib file
您应该执行以下操作:
\documentclass[a4paper,10pt]{article}
\usepackage[natbib, % To use natbib commands
style=authoryear, % Style of cites and bib entries
backend=bibtex8] % To use bibtex instead biber
{biblatex}
\addbibresource{bib.bib} % Loading .bib file
\renewbibmacro{in:}{% % To remove "In:" from articles
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}
\DefineBibliographyStrings{english}{pages={pages}} % To change default pp.
\DefineBibliographyStrings{english}{page={page}} % To change default p.
\begin{document}
\citet{easterly2009can,frankel1999does} % Cite as if you were using natbib
\printbibliography % Equivalent to \bibliography{bib}
\end{document}
有了这个bib.bib
:
@Article{ easterly2009can2,
Author = "William Easterly",
Title = "Can the West Save Africa?",
Journal = "Journal of Economic Literature",
Pages = "373--447",
year = 2009,
note = "A comment that should be before",
addendum = "A comment after"
},
@Article{ frankel1999does2,
Author = "J.A. Frankel and D. Romer",
Title = "Does trade cause growth?",
Journal = "American Economic Review",
Pages = "379--399",
year = 1999,
note = "A comment that should be before",
addendum = "A comment after"
}
但是,我找不到如何重新排序每个 bibtex 条目中的块实体。也许你运气更好。
我应该指出,引用和书目样式可能会改变。请查看 biblatex 文档以了解详情。这是自定义 biblatex 样式的问题。
接下来的问题:如何以简单的方式引用所有没有注释的 bib 条目?(对文件进行微小的更改,.bib
不会影响文件的正常使用)
\documentclass[a4paper,10pt]{article}
\usepackage[natbib, % To use natbib commands
style=authoryear, % Style of cites and bib entries
backend=bibtex8] % To use bibtex instead biber
{biblatex}
\addbibresource{biblong.bib} % Loading .bib file
\renewbibmacro{in:}{% % To remove "In:" from articles
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}
\DefineBibliographyStrings{english}{pages={pages}} % To change default pp.
\DefineBibliographyStrings{english}{page={page}} % To change default p.
\begin{document}
\citet{easterly2009can,frankel1999does} % Cite as if you were using natbib
\section*{References}
% use \fullcite[prenote][posnote]{bibentrylabel}
\noindent \fullcite[*][Please read sections 32-33]{easterly2009can} \\
\noindent \fullcite[*][Please read sections 2-4]{frankel1999does} \\
\nocite{*} % Use of \nocite is not necessary if they were cited elsewhere
% The following command only print entries that not have the keyword annotated
\printbibliography[notkeyword=annotated,heading=none]
\end{document}
有了这个biblLong.bib
:
@Article{ easterly2009can2,
Author = "William Easterly",
Title = "Can the West Save Africa?",
Journal = "Journal of Economic Literature",
Pages = "373--447",
year = 2009
}
@Article{ frankel1999does2,
Author = "J.A. Frankel and D. Romer",
Title = "Does trade cause growth?",
Journal = "American Economic Review",
Pages = "379--399",
year = 1999
}
@Article{ lennon1965help,
Author = "John Lennon",
Title = "Help!",
Journal = "The Beatles",
Pages = "1--14",
year = 1965
}
@Article{ mccartney2003let,
Author = "Paul McCartney",
Title = "Let it be... Naked",
Journal = "The Beatles",
Pages = "1--11",
year = 2003
}