Help me build a better .bib?
September 14, 2010 11:08 AM Subscribe
I have a LaTeX paper with BibTex citations. I have a massive central .bib file. I want a script that builds a subset of my central bib containing only the citations I used in a particular paper. Is there a script for this?
I maintain a large, single BibTex file containing essentially every paper I've ever read that might be worth citing. I write papers in LaTeX. Right now, I create a symlink from my paper's working directory to my master bibtex file, so I can cite anything. I'd like to be able to run a script against my .tex documents, extract all the citations, find those citations in my master .bib, and create a new .bib containing only the cites I used in that paper (that I can distribute with the paper to other authors, etc).
I'm pretty sure I could write a Ruby script to do this, but I don't want to spend the time if someone else has already written a script/app to do this. Don't really care about the language, so long as it runs on a Mac. Does such a thing exist?
I maintain a large, single BibTex file containing essentially every paper I've ever read that might be worth citing. I write papers in LaTeX. Right now, I create a symlink from my paper's working directory to my master bibtex file, so I can cite anything. I'd like to be able to run a script against my .tex documents, extract all the citations, find those citations in my master .bib, and create a new .bib containing only the cites I used in that paper (that I can distribute with the paper to other authors, etc).
I'm pretty sure I could write a Ruby script to do this, but I don't want to spend the time if someone else has already written a script/app to do this. Don't really care about the language, so long as it runs on a Mac. Does such a thing exist?
Oh, doh, ignore me. Completely wrong end of the stick. Have you looked at BibDesk's export features?
posted by holgate at 11:37 AM on September 14, 2010
posted by holgate at 11:37 AM on September 14, 2010
Response by poster: I may have poorly described my setup, so apologies. My problem isn't in output (which has always worked fine for me), but in wanting to create a subset of my bibliographic entries -- just those I'm using in the current paper -- which I can distribute to coauthors.
I have a master .bib that contains several hundred citations. I don't really want to be mailing around my entire citation database with the paper, however. What I'd like to do is generate a subset of my .bib file that I can distribute, which contains just the citations needed to build the final document, without all the other hundreds of citations.
posted by Alterscape at 11:39 AM on September 14, 2010
I have a master .bib that contains several hundred citations. I don't really want to be mailing around my entire citation database with the paper, however. What I'd like to do is generate a subset of my .bib file that I can distribute, which contains just the citations needed to build the final document, without all the other hundreds of citations.
posted by Alterscape at 11:39 AM on September 14, 2010
Response by poster: On failure to preview -- I use BibDesk, but I'd like to automate the process of creating a subset. I suppose I could create a tag (ie, "used_in_conference_xxx" or something) and then search that tag, select all, export, but that still seems silly since I have a perfectly good list of the citations I'm using embedded inside my .tex source!
posted by Alterscape at 11:41 AM on September 14, 2010
posted by Alterscape at 11:41 AM on September 14, 2010
It may not be exactly what you want, but when you build the bibtex bibliography for YourFile.tex, it generates a YourFile.bbl that is basically just the normal LaTeX for the particular bibliography. You should be able to either send that directly to a colleague or, if you wanted something prettier, paste it into a blank document and render it to pdf.
posted by Schismatic at 11:45 AM on September 14, 2010
posted by Schismatic at 11:45 AM on September 14, 2010
Okay, picking up on Schismatic's comment: tex2bib isn't the most elegant solution -- it takes .bbl output and reformats it to .bib -- but if you're not doing anything fancy with BibTex fields and formatting, it might work for you.
posted by holgate at 12:37 PM on September 14, 2010
posted by holgate at 12:37 PM on September 14, 2010
Best answer: I'm using JabRef to manage the bibliography of a project I'm working on, and it has exactly the feature you want. Once you've loaded a .bib file into JabRef, it's one or two clicks to have it export just the subset of items used in a particular paper. Apparently it can also do the same trick from the command line, which I didn't know until a couple of minutes ago!
posted by logopetria at 1:50 PM on September 14, 2010 [1 favorite]
posted by logopetria at 1:50 PM on September 14, 2010 [1 favorite]
Best answer: BibDesk lets you select from an .aux file, and once you've done that, you've got the n citations you've used in your paper, which you can then export to a new BibDesk .bib file. It's like three clicks: when you're over in the left-hand area (i.e., not in your citations, so the menu items aren't grayed out):
Database Menu/Select Publications from .aux file
Now, choose the .aux from the .tex file you've already got. then:
File/Export... and check "only export selected files"
and you've got what you want.
posted by leahwrenn at 3:27 PM on September 15, 2010 [1 favorite]
Database Menu/Select Publications from .aux file
Now, choose the .aux from the .tex file you've already got. then:
File/Export... and check "only export selected files"
and you've got what you want.
posted by leahwrenn at 3:27 PM on September 15, 2010 [1 favorite]
This thread is closed to new comments.
Have you got a \nocite{*} lurking somewhere in your template that's pulling in all the .bib entries?
posted by holgate at 11:34 AM on September 14, 2010