3

How can I create a single reference list that contains precisely the items cited in at least one of several distinct documents? I do not want to include any references that not actually cited, but the citation can come from one of several documents, and the reference list should be, again, a separate document.

Motivation: This seems to be what is requested by the grant proposal guidelines for the NSF.

Additional information: I'm using BibTeX (with BibDesk on Mac OS X). The references all come from a single *.bib file.

  • In other words, you want a document to know which bib items have been cited in other external documents? – karlkoeller Oct 16 '13 at 19:28
  • @karlkoeller: Essentially, yes. – Charles Staats Oct 16 '13 at 19:47
4

Bibtool can do a lot of the work for you. Take this .bib file:

% masterfile.bib
@InProceedings{a,
  crossref =     {z},
  author =       {Author, A.},
  year =         {2001},
  title =        {Alpha},
}
@InProceedings{b,
  crossref =     {z},
  author =       {Buthor, B.},
  year =         {2002},
  title =        {Bravo},
}
@Proceedings{z,
  editor =       {Zuthor, Z.},
  year =         {1999},
  title =        {Zulu},
  publisher =    {Publisher},
  address =      {Address},
}

@Book{book,
  author =   {Smith, John},
  title =    {A Book Title},
  publisher =    {Publisher},
  year =     2000,
  address =      {Address}}

@Article{article,
  author =   {Smythe, Jon},
  title =    {An Artitle Title},
  journal =      {Journal of Journals},
  year =     2000,
  volume =   10,
  number =   2,
  pages =    {100--125}}

@Book{notcited,
  author =   {Schmit, Jean},
  title =    {An Uncited Book},
  publisher =    {Publisher},
  year =     2001,
  address =      {Address}}

Now imagine two different input files:

% file1.tex
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\begin{document}

\cite{a,b,book}

\bibliographystyle{plain}
\bibliography{masterfile}
\end{document}

and

% file2.tex
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\begin{document}

\cite{article,book}

\bibliographystyle{plain}
\bibliography{masterfile}
\end{document}

We want to construct a new .bib (say: newbibfile.bib) that contains the following bib entries: a, b, z, article, and book (but not notcited). Run latex (or lua|pdf|xelatex) on your two .tex files. This produces the all-important .aux file that bibtool can read. The bibtool command is:

bibtool -x file1.aux -o newbibfile.bib && bibtool -x file2.aux >> newbibfile.bib

This command extracts from file1 and creates the new .bib file, then the second call uses >> to append its output to the already-created newbibfile.bib. (If you have more than two files you need to extract from, modify the above command accordingly.)

... Now, many will note that both files cited the entry book, which means there will be two book entries in newbibfile.bib; this is no good. Good BibTeX-aware editors can help you find and deal with them [Emacs plug!], but bibtool can also detect entry key duplicates:

bibtool -d newbibfile.bib

If you want to combine all this into a one-liner, you could do:

bibtool -x file1.aux -o temp.bib && bibtool -x file2.aux >> temp.bib && bibtool -d temp.bib -o newbibfile.bib

In our use case, bibtool helpfully warns:

*** BibTool WARNING: Possible double entries discovered: 
***     book =?= book
***     book

and the second book entry in newbibfile.bib is marked by ###. Just find your duplicate entries and delete them.

2

Just for completeness sake, a solution with BibDesk:

  1. Generate all the files given in the answer by @jon
  2. Open masterfile.bib in BibDesk
  3. Create a new bibliography and save it as newbibfile.bib
  4. Go to masterfile.bib and select Database —> Select Publications From .aux File in the menu
  5. Choose file1.aux
  6. Drag the resulting selection of entries into the window containing newbibfile.bib
  7. Repeat steps 3 through 6 with file2.aux
  8. Select duplicates (Database —> Select Duplicates) and delete them, in order to clean up newbibfile.bib.

Eventually you can print the reference list as a separate document, like this:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\begin{document}

\nocite{*}
\bibliographystyle{plain}
\bibliography{newbibfile}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.