10

I am writing a scientific paper with supplementary information in an additional document. The paper and the supplement share many references, which in the paper are numbered by first appearance in the text.

I would like the references in the supplement to have the same numbers as in the paper. I have additional references there and not all references from the paper show up in the supplement.

I am still working on the documents and the .bib-file is changing. It is generated by Icculus Referencer.

Is there a way to achieve the numbering the way I like? I haven't tried, but I think, that one way could be to create a .bib-file with all references that I want to use and then number all of them, regardless of their use in the current document. The problem is, that when I change the first appearance of one reference, I have to change the order of the bibtex-entries in the .bib-files, which is not very handy.

Werner
  • 603,163

2 Answers2

2

A solution I used is to keep both documents as a single document until the very end. Then manually split the bibliography and adjust the appropriate counters as discussed in this answer. You can also reset the page counter for the supplementary material when submitting (but keep consecutive pages if you post the complete document somewhere like a preprint server or for your own use).

This is a bit of a pain, but since (for me) I need to manually include the .bbl file in the main text for both the preprint server and the final submission, it is not really that onerous.

By using some hooks from etoolbox, all I need to do is to figure out where to split the bibliography, then include two separate bibliographies in the file. (I put all of this stuff and a copy of the preamble from the .bbl file in a local style file so I don't have to worry about it when writing the paper.)

\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}

References

mforbes
  • 5,571
2

You could try using the \nocite command (see this Wikibook entry for a quick explanation)... there's also a \nocite{*} command to list a whole bib file (see this TeX FAQ entry).

EDIT: referring to my comment below... I came up with an UGLY Python script to do just that:

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 ()

change input (in.tex) and output (out.tex) as needed, run it through Python, and you'll get the \nocites in the order in which they first appeared in the input file.

Hope it helps! ;)

EDIT 2: changed the regular expression to support all the cite type given in this Wikibook entry.

David Carlisle
  • 757,742
mpr
  • 3,646
  • 3
    \nocite{*} is helpful for listing uncited bibentries in the bibliography. The OP's question, however, is about a "unified" numbering scheme for multiple documents. – lockstep Dec 08 '11 at 19:04
  • @lockstep: Although this is not the answer to my problem, it hints to a painful workaround. Using \nocite{*} on a bibliography, that is preordered according to first appearance of citations in a document, I get the right numbering of citations in the document, but unfortunately all the references are listed in both documents. If I could find a way to filter the unused ones out again, I would be fine. Unfortunately there are 2 problems: 1. I have to presort the bibliography, 2. I don't know, how to eliminate the unused references. – Amelse Etomer Jan 06 '12 at 01:25
  • I think one could write a Python / Perl / Bash / whatever script to get the reference's keys from your "main" paper (by looking for \cite commands), then write out \nocites for them to a file, say mainrefs.tex. Then in your "secondary" paper you could \input{mainrefs} at the very beginning ;) – mpr Jan 06 '12 at 12:10
  • Done just that in the answer proper ;) – mpr Jan 06 '12 at 14:27