我正在将我的论文写成论文集,我想在论文结尾处列出完整的参考书目。由于有多个参考资料用于多个章节,我想在每一章中“重置”包longnamesfirst
的选项natbib
。这里以 MWE 为例。
\documentclass[11pt,a4paper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[round,longnamesfirst]{natbib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{ahuja2002,
author = {Ahuja, R.K. and Ergun, {\"O}. and Orlin, J.B. and Punnen, A.P.},
title = {A survey of very large-scale neighborhood search techniques},
journal = {Discrete Applied Mathematics},
year = {2002},
volume = {123},
pages = {75--102},
number = {1},
publisher = {Elsevier}
}
\end{filecontents}
\begin{document}
\chapter{First chapter}
\cite{ahuja2002}\\
\chapter{Second chapter}
\cite{ahuja2002} $\leftarrow$ That guy should be ``longnamesfirst'' as well!
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
我用memoir
文档类进行论文,因此问题被标记回忆录也一样。
答案1
这是实现此目的的一种方式。Natbib 通过在第一次引用每个键时定义一个特殊宏来实现此目的。后续引用将检查此宏。因此,我们需要做两件事:(1) 在每章开始时取消定义这些宏,(2) 了解所有可能键的列表。
后者是通过知道引用的键在辅助文件中来收集的,因此我们重载\bibcite
以将键添加到全局列表中。然后在每章开始时循环遍历该列表。(标题之后)
\documentclass[11pt,a4paper]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[round,longnamesfirst]{natbib}
\usepackage{etoolbox}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{ahuja2002,
author = {Ahuja, R.K. and Ergun, {\"O}. and Orlin, J.B. and Punnen, A.P.},
title = {A survey of very large-scale neighborhood search techniques},
journal = {Discrete Applied Mathematics},
year = {2002},
volume = {123},
pages = {75--102},
number = {1},
publisher = {Elsevier}
}
\end{filecontents}
%\bibcite{ahuja2002}{{1}{2002}{{Ahuja et~al.}}{{Ahuja, Ergun, Orlin,
%and Punnen}}}
\let\bibitemkeylist\relax
\AtEndPreamble{
\let\normalbibcite\bibcite
\renewcommand\bibcite[2]{%
\listgadd{\bibitemkeylist}{#1}
\normalbibcite{#1}{#2}%
}
}
\makeatletter
\newcommand\RESETHANDLER[1]{\global\cslet{bv@#1\@extra@b@citeb}\relax}
\newcommand\RESET{
\forlistloop\RESETHANDLER\bibitemkeylist
}
\renewcommand\memendofchapterhook{\RESET}
\makeatother
\usepackage{hyperref}
\begin{document}
\chapter{First chapter}
First: \cite{ahuja2002}
Second: \cite{ahuja2002}
\chapter{Second chapter}
First: \cite{ahuja2002}
Second: \cite{ahuja2002}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}