Zen moments are common if you use a lot of open-source software. Sometimes you download software, work your way through some tutorials and how-tos and scan mailing lists, but you don’t quite see what all the fuss is about. Then one day you have your zen moment – “Aaah!” – when you get it.
It’s taken way too many years but this week, I finally had my LaTeX zen moment.
Hardcore users of LaTeX will find nothing here. If you’re considering the LaTeX + BibTeX solution to writing but are unsure of how to go about it, you may find these ramblings useful – especially on Ubuntu. I’ve also put together a basic, public Google Notebook with a few useful links.
First, I have a terrible confession to make. I’ve written a few scientific papers in my time and I have never used a reference manager or bibliography software. Normally, I copy and paste references on the fly from a PubMed search at NCBI and format them later.
Isn’t that dreadful?
So what’s my excuse? I don’t use Windows or Mac, so the Word + Endnote option is not available (OK, perhaps with wine, but I don’t want to go there). However, I generally work with Word users who ask me for Word files. OpenOffice can provide these, no problem, but bibliography software options for OpenOffice are woeful – practically non-existent. So it’s OpenOffice, manual handling of the bibliography and save to Word.
For years of course, I’ve been dimly aware of alternatives and I’ve installed and played around with a lot of them. I’ve tried many reference managers – wikindx, refbase, refdb. I’ve tried pybliographer. I’ve tried ODBC/JDBC drivers to interface OpenOffice to databases. I’ve installed every LaTeX-related package in the Ubuntu repository and completed several LaTeX “my first document” tutorials (several times). I’ve looked at tex using emacs. Until now though, I never put it all together in a way that satisfied me.
My problem has been that I’m on an eternal quest for the perfect reference/bibliography system under Linux. There is no such thing of course – what you need to do is figure out your needs, investigate the options and implement what works for you.
I don’t enjoy writing papers – I’d much rather be writing Perl. Each time that I have to write, I find myself procrastinating for days with my “perfect system” quest. Then I get stressed because I’m procrastinating. Eventually I figured out why I was procrastinating – it’s because I’m unhappy with my work setup. I was unable to slip easily into “paper writing mode” because subconsciously I knew that things were not right and it was going to be hassle. It’s at this point that you realise that something needs to be done. It’s not procrastinating – it’s taking action to fix a problem.
Figure out what you need to do
Here’s what I need to do regularly and with minimal hassle:
- Fetch references from PubMed, either individually or in a batch
- Store them, somewhere, somehow
- Incorporate them into a document easily as I write and cite them in a journal style
- Optionally, share both references and documents in a variety of formats with other people
The reference format
BibTeX appeals to me. It’s a simple, plain text readable format. It’s easy to obtain, convert and store. It’s also the basis of bibliographies in LaTeX. The simplest reference database is just a directory of BibTeX files and that may well be all you need.
Bibutils is an indispensable toolkit for converting between BibTex and other formats. It’s easy to compile or else available as an Ubuntu package. Bibtool is rather more cryptic but handy for fixing broken BibTeX – removing duplicate entries and so on.
The reference database
I searched Sourceforge for “bibtex database” and found quite a few projects – most of which were yet to release files or else not updated for many years. There were issues with all of the BibTeX-specific database software that I tried.
I’m relatively happy with both wikindx and refbase. I tend towards the latter because of its excellent import facilities – it can import using a list of PubMed PMIDs, for instance. It also offers the best current solution for OpenOffice integration, in the form of export to ODF XML which you can then use as an OO bibliography database.
Journal style files
Enlightened publishers such as BioMed Central provide you with style files for LaTeX. You could install them system-wide but if your Linux distro is package-based, it’s probably best to put them in a special location. This guide explains how to do just that. Put your .cls in ~/texmf/tex/latex, your .bst in ~/texmf/bibtex/bst and don’t forget to run “texhash” afterwards. Voila, BMC (or whatever) style is now available to you.
Writing and citing
It’s crunch time – let’s write. I’ve tried a few solutions for editing LaTeX documents. At one extreme we have the GUI, at the other a plain text editor environment. For the former I’ve tried Lyx and didn’t like it much. Purely personal – it’s a good piece of software, but I found the graphical environment distracting. It also distances you from the tex via its own intermediate format which I feel is a disadvantage. For instance, it may not play nice with your existing tex files (I found this to be the case for the BMC tex template). On the plus side, citation directly from pybliographer via lyxpipe is a nice feature.
The plain-text only approach? You can’t get past emacs for my money, but be prepared for quite a steep learning curve.
What I was really looking for was a half-way house which allowed me to see the source without distracting me from the document (or vice-versa) and remove some of the pain associated with compiling to DVI etc. In other words, a LaTeX IDE. I can report that I have found my LaTeX saviour and her name is kile.
In the Gnome v. KDE wars I’m a Gnome man – I just prefer the look – but of course KDE apps run fine under Gnome and I use many of them. Kile is just brilliant. You just open up your LaTeX plus your BibTeX and start editing. At any point hit the Quick Build button and your DVI pops up. All your other tools are built in (latex2html, PDF, PS etc.), syntax highlighting is great, there are consoles down at the bottom for messages and a host of other features. This really is software that I can just fire up and use without stress. Kile also uses the same ~/.lyx/lyxpipe as Lyx so if you like you can open up your references in pybliographer, find the ones you need and cite straight into Kile. It really is a joy to click a button and see your paper pop up in the correct journal style, without manually going through that “latex, latex, bibtex, latex” cycle.
(Completely unrelated – for those occasions when people send you Word files and you want to convert to something useful – “sudo apt-get install wv”. The wv package lets you convert Word to all sorts of formats including tex and worked nicely for me using the Word output of OpenOffice).
Toolkit and workflow
At long last then, I have a system:
- Grab references from PubMed as required, import to refbase
- Export from refbase as BibTeX bibliographies
- Write my documents using Kile, optionally citing via pybliographer
- Harness the power of LaTeX to export to multiple formats
I’ll never get to reference/bibliography nirvana, but at least I feel a few steps closer.