我正在撰写一篇科学论文,并在附加文件中添加了补充信息。该论文和补充文件共享许多参考文献,论文中的参考文献按在正文中首次出现的位置进行编号。
我希望附录中的参考文献编号与论文中的相同。我在那里添加了其他参考文献,但论文中的参考文献并未全部显示在附录中。
我仍在处理这些文档,文件.bib
正在发生变化。它由Icculus 参考资料。
有没有办法按照我喜欢的方式进行编号?我还没有尝试过,但我认为一种方法是创建一个.bib
包含我想要使用的所有参考文献的文件,然后对它们进行编号,而不管它们在当前文档中的用途。问题是,当我更改一个参考文献的首次出现时,我必须更改文件中 bibtex 条目的顺序.bib
,这不是很方便。
答案1
我使用的解决方案是将两个文档保留为单个文档,直到最后。然后手动拆分参考书目并调整适当的计数器,如这个答案。您还可以在提交时重置补充材料的页码计数器(但如果您将完整文档发布到预印本服务器等地方或供自己使用,请保留连续的页面)。
这有点麻烦,但由于(对我来说)我需要手动将.bbl
文件包含在预印本服务器和最终提交的正文中,所以其实并不是那么繁重。
通过使用 中的某些钩子etoolbox
,我所需要做的就是找出在哪里拆分参考书目,然后在文件中包含两个单独的参考书目。(我将所有这些内容和文件中序言的副本.bbl
放在本地样式文件中,这样在撰写论文时就不必担心它了。)
\documentclass[aps, prl, twocolumn]{revtex4-1}
\usepackage{etoolbox} % Provides ability to hook into thebibliography
\makeatletter % Some cmds have @ in them. Not needed if in a .sty file
\newcounter{firstbib} % New counter: keeps track of the next first number
\AtBeginEnvironment{thebibliography}{
% Insert the first portion of the .bbl file here defining any formatting
% macros
}
% Can't use \AtBeginEnvironment for the next bit since that is too early.
% We need to set the counter *after* the \thebibliography command is used.
\apptocmd{\thebibliography}{
\setcounter{NAT@ctr}{\value{firstbib}} % Use this for natbib and revtex
%\setcounter{enumiv}{\value{firstbib}} % ... or you might need to use this
}{}{} % These args are for errors handling: see etoolbox docs
\AtEndEnvironment{thebibliography}{
\setcounter{firstbib}{\value{NAT@ctr}}
%\setcounter{firstbib}{\value{enumiv}}
}
\begin{document}
\title{A Great Paper (with Supplementary Material)}
\begin{abstract}\noindent
This demonstrates using two bibliographies with continuous numbering, but
separation into a main bibliography and a supplementary bibliography.
\end{abstract}
\maketitle
\noindent
First write the paper with a single bibliography and cite everything as
normal. Then, when finished, manually split the \texttt{.bbl} file in two at
the appropriate place and include each portion in its own environment.
Adjust the counters as needed. Here is a reference in the main text:
\cite{Zwerger:2011}.
% Use these as needed when working, and use bibtex.
%\bibliographystyle{apsrev4-1}
%\bibliography{master}
% Insert the first portion of the .bbl file here:
\begin{thebibliography}{74}
\bibitem{Zwerger:2011}%
W.~Zwerger, ed., \emph{The BCS--BEC Crossover and the Unitary Fermi Gas},
Lecture Notes in Physics, Vol.~836 (Springer-Verlag, Berlin Heidelberg,
2012) \makeatletter
\end{thebibliography}
\clearpage
\newpage
\setcounter{page}{1}
\section{Supplementary Material}\noindent
Here is some supplementary material. You can refer to the original
references~\cite{Zwerger:2011} or include new references~\cite{Forbes:2012}.
\begin{thebibliography}{74}
\bibitem{Forbes:2012}%
M.~M.~Forbes, S.~Gandolfi, and A.~Gezerlis, Phys.~Rev.~A \textbf{86},
053603 (2012)
\end{thebibliography}
\end{document}
参考
答案2
您可以尝试使用\nocite
命令(参见维基百科条目简要解释一下)...还有一个\nocite{*}
命令可以列出整个bib
文件(参见TeX 常见问题解答)。
编辑:参考我下面的评论...我想出了一个丑陋的Python 脚本可以完成这个任务:
import re
# input and output files
input = 'in.tex'
output = 'out.tex'
# remove duplicates whilst preserving order
def uniq (seq):
seen = set ()
seen_add = seen.add
return [x for x in seq if x not in seen and not seen_add (x)]
# pattern to look for
pat = '((\\cite)|(\\citet)|(\\citep)|(\\citet\*)|(\\citep\*)|(\\citeauthor)|(\\citeauthor\*)|(\\citeyear)|(\\citeyearpar)|(\\citealt)|(\\citealp))(\[.*?\])?\{(.*?)\}'
# get the file
f = open (input)
#read it into i
i = f.read ()
# close it
f.close ()
# get the list of references, with no duplicates, and preserving order
ms = uniq ((','.join ([(list (x))[-1:][0] for x in re.findall (pat, i)])).split (','))
# initialize output to empty string
o = ''
# for every reference...
for m in ms:
# generate \nocite command
o += '\\nocite{' + m + '}\n'
# open output file
f = open (output, 'w')
# write output away
f.write (o)
# close it
f.close ()
根据需要更改input
(in.tex
)和output
( ),通过 Python 运行它,您将按照它们在输入文件中首次出现的顺序获得 s。out.tex
\nocite
希望能帮助到你! ;)
编辑 2:更改正则表达式以支持给定的所有引用类型在此 Wikibook 条目中。