Wednesday, January 23, 2008

My PhD Thesis: in color and grayscale

Wednesday is my regular day off from my metabolomics work, and today I am finalizing the layout of my thesis, which I'll defend on April 2. The print version will feature grayscale images with some of them in color too. However, the PDF version that will end up in our university repository should have color prints. So, while halfway creating suitable grayscale versions of the image, I realized I was not doing it properly. I was replacing the images; so, I lost the color version. Not good.

But wait, LaTeX can do more; why not have a color and a grayscale option? Here comes optional.sty. By adding \usepackage{optional} I can add to the source (from book.tex):
\caption{a) 2D diagrams of the two possible resonance structures of a compound
with a phenyl ring. Both diagrams refer to the same compounds, but the depicted
graph representations are not identical. b) 2D diagram of ferrocene, which,
like all organometallic compounds,
is difficult to represent with classical chemoinformatics approaches.}
Ferrocene was already black-and-white, so no worry about that. And, it is just the red colored hydroxyl group. But it serves the point :)

Which then allows me to run pdflatex to create a color version and a grayscale version:
pdflatex "\def\UseOption{color}\input{book}"
pdflatex "\def\UseOption{grayscale}\input{book}"

/me is happy


  1. Another method would be to wrap the graphicspath command from graphicx in an opt command and then just separate color and greyscale figures into two different directories.


    Just a though.

  2. Yes, swapping graphicspath is much less typing later on. Did that too ;-)


  3. Eric, good suggestion. Won't work for me this time, though: I have the resources for each chapter in separate subfolder... as they have been published as individual papers too... but will remember this for next time!

  4. You do metabolomics work too? I tend to work on it as a hobby in my spare time. I've been writing scripts to do faster mass spectrometry metabolite id. What do you do?

  5. Hi Mitch,

    similar kind of things. Right now, our work focuses on GC/MS and LC/MS data, and we work on setting up webservices for metabolomics at Plant Research International (, and we work on the opensource project MetWare.

    What are your scripts doing? Are they working in the data preprocessing step? Talking mass or NMR spectra and compare against databases?

  6. Yup. It takes the masses from CE-MS and compares to an in-house metabolite database, and of course takes into account common adduct products and isotopes. Really nice and straightforward stuff. It's completely written in php and I'm considering running it as a simple server side operation since most biologists and analytical chemists get scared of dos prompts.