29

My colleague asked me to write a page for a paper he writes. I wrote the page in LyX, compiled it to LaTeX, and sent him the TeX files. Then he reminded me that I forgot to send the .bib file with all the references.

But, my .bib file is huge - it contains over 1000 references (I have a global BiBTeX file for all my papers). The page I wrote uses only about 20 of them.

Is there an automatic way to extract from the bib file, only the records relevant to the current paper?

Torbjørn T.
  • 206,688
  • You could send him the .bbl file (provided that you haven't used the \nocite{*} command, or else you'll get ALL your bibliography file). – Mario S. E. Oct 07 '13 at 17:01
  • 2
    JabRef can for example create a new .bib-file based on a .aux file, see http://tex.stackexchange.com/questions/98370/how-to-generate-a-bib-file-with-citations-in-a-texmaker-project/98396#98396 See also http://tex.stackexchange.com/questions/41821/creating-bib-file-containing-only-the-cited-references-of-a-bigger-bib-file – Torbjørn T. Oct 07 '13 at 17:02
  • @MarioS.E. I don't see any bbl file; – Erel Segal-Halevi Oct 07 '13 at 18:15
  • @TorbjørnT. I don't see any .aux file... I only have .bib and .tex . – Erel Segal-Halevi Oct 07 '13 at 18:16
  • 1
    Ah, sorry (on two counts). The .aux file is generated when you run pdflatex on the .tex file. Also, do you use biblatex as the tag suggests? In that case you probably have to add backend=bibtex as an option to the biblatex package before you compile. – Torbjørn T. Oct 07 '13 at 18:33
  • Thanks! This is what I did: "pdflatex myfile.tex" "bibtool -x myfile.aux > myfile.bib" – Erel Segal-Halevi Oct 07 '13 at 19:16
  • I am not sure about bibtex/biblatex. I just used LyX's "export to LaTeX" command. – Erel Segal-Halevi Oct 07 '13 at 19:16

3 Answers3

22

If you want to give a bib file away only including entrys which are cited in a document use package bibexport. If you have a main TeX file mwe.tex and want to create a short bib file short.bib use:

bibexport.sh -o short.bib mwe.aux

You get an resulting bib file short.bib containing only cited/crossreferenced entrys from your main bib file.

Mensch
  • 65,388
12

One solution would be to use bibtool. It only works with BibTeX though, not Biblatex.

Use the following command to extract relevant entries:

bibtool -x myfile.aux > myfile.bib
xuhdev
  • 1,083
twsh
  • 2,718
7

Through the compilation a file .bbl is created. There are the relevant references of your manuscript.

You could insert the content of this file directly on the .tex in the place of the bibliography (erasing the command \bibliography{....bib} of your original text).

Dox
  • 5,729