Pages

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):
\begin{figure}[bt]
\begin{center}
\subfigure[]{
\label{fig:benzene:a}
\opt{color}{\includegraphics[width=0.4\textwidth]{intro/benzoCompounds_color}}
\opt{grayscale}{\includegraphics[width=0.4\textwidth]{intro/benzoCompounds}}
}
\hspace{2cm}
\subfigure[]{
\label{fig:benzene:b}
\includegraphics[width=0.18\textwidth]{intro/Ferrocene-2D}
}
\end{center}
\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.}
\label{fig:benzene}
\end{figure}
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

6 comments:

  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.

    \opt{color}{\graphicspath{{figs-color/}}
    \opt{grey}{\graphicspath{{figs-grey/}}

    Just a though.

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

    Yours,
    Steffen

    ReplyDelete
  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!

    ReplyDelete
  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?

    ReplyDelete
  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 (www.pri.wur.nl), 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?

    ReplyDelete
  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.

    Mitch

    ReplyDelete