Monday, 16 February 2015

[Tex] extract a bib file for submission to the conference or the journal with tex file together when you use a big bib file in writing

1. Background
I am using the Jabref for references management. Usually I use a database for all references, let's say "ref.bib". When I am writing the paper, I just let it include "\bibliography{/path/to/ref}" in the tex file. If I just need to submit the paper in pdf format only, that is great and nothing to do with the bib file.

However, if the conference or journal requires the paper in tex format, I have to include all uncommon latex packages as well as the bib file. It is not wise to include the large "ref.bib" in my case. Instead, I prefer extracting the entries used in this paper and putting them in a separate small bib file, let's "ref.bib", in the local folder.

This is about how to extract the entries from a bib file managed by Jabref to a small bib file according to the used references in a paper. My approach is to use the bibtool.

2. Bibtool
2.1 Download bibtool from CTAN
BibTool-2.58.tar.gz

2.2 How to build on Mac OS X
You need gcc to build it. 
  • Decompress BibTool-2.58.tar.gz
$ tar xvf BibTool-2.58.tar.gz
  • Copy makefile.unx to Makefile
$ cp maekfile.unx Makefile
  • Then just make, the binary bibtool would be in the same folder
$ make

2.3 Installation
You can follow the instructions in install.tex to install it by "$ make install", or just run bibtool with the absolute path (such as ~/bibtool/bibtool), or put it in a folder in your path (in my case, it is copied to ~\bin).

3. Practice
3.1 Sort the original bib file by bibtool to see what problems it may have
$ bibtool -s /path/to/ref
3.2 Some ERRORs occur
3.2.1 Unknown entry type
  • Add additional resource file called "res.txt" and add the missing entry types to this file.
new.entry.type {Electronic}
new.entry.type {Other}
new.entry.type {Standard}
new.entry.type {comment}
  • Then add "-r res.txt" to include the resource file, which eliminates this ERROR
$ bibtool -r res.txt -x paper.aux -o paper.bib
3.2.2 Symbol does not start with a letter
Jabref uses __markedentry to mark an entry that has marked color, but that is not a valid item by bibtool. Then an ERROR "Symbol does not start with a letter" occurs.
  • One way to do is to unmark the item in Jabref
3.3 Build the paper.tex to pdf by bibtex and pdflatex
You will see an additional paper.aux file generated in addition to the paper.pdf file.

3.4 Extract all entries for the paper to a bib file
$ bibtool -r res.txt -x paper.aux -o ref.bib
3.5 The local ref.bib file includes all entries for the paper. So just replace "\bibliography{/path/to/ref}" in the tex file to "\bibliography{ref}" that uses the local ref.bib file. Then I can submit this ref.bib with the tex file together.

No comments :

Post a Comment