## LaTeX is amazing

I’ve long been a convert to the wonderful typesetting engine LaTeX, but it wasn’t until very recently that I fully understood its power. Given my very untidy handwriting, I keep my entire lab book in LaTeX. It includes many images of gels, such as the one below.

Biologists will recognise what this means – it is basically a slab of jelly which I’ve run some fragments of DNA through, from top to bottom. The smaller fragments run faster and represent the bands near the bottom. The middle ‘ladder’ is a mixture of fragments of known sizes. The lanes outside it contain unknowns which I want to measure in comparison to the ladder. So far, so standard.

What is special about this gel is the clean image above it. This is a simulation – what do I expect a gel to look like if it has certain band sizes? It just makes it very simple to see if we have what we expect, without looking up the exact details of the ladder. There are a number of tools for making these by hand, but this simulation was created in the typesetting engine itself, with just a few custom macros. This is the underlying Tex:

\begin{gelsim}
\gelscale{40} \geloffset{3}
\lane[Digestion A] \band{3500} \band{600}
\lane[Digestion B] \band{3500} \band{600}
\lane[Digestion C] \band{1400}
\lane[Digestion D] \band{1400}
\end{gelsim}



Pretty self-explanatory I hope. This isn’t a feature built into LaTeX: it works because of a custom class I hacked together (warning: totally uncommented and horrible). But it is totally amazing that it is possible at all. The class could use quite a bit of improvement, but it’s suiting my purposes for now.

The class itself is only 62 lines of code. Before spending a few hours hacking this together, I had no idea that LaTeX could even calculate logarithms on the fly!

If anyone is trying to replicate this you’ll also need to define the ladder in your preamble. And the last line of the code above should be ignored, just include the image as you would normally.

Happy lab booking!

Tags: , ,

### 4 Responses to “LaTeX is amazing”

LaTeX is amazing « Splasho…

2. Wonderful web site. Lots of helpful information here.

I’m sending it to a few friends ans additionally sharing in delicious.
And naturally, thank you on your sweat!

3. tee shirt says:

Hi there I am so delighted I found your blog page, I
really found you by accident, while I was searching on Yahoo for
something else, Anyhow I am here now and would
just like to say thanks a lot for a incredible post
and a all round interesting blog (I also love the theme/design),
I don’t have time to read it all at the minute but I have saved it and also included
much more, Please do keep up the great b.

4. As a Newbie, I am continuously browsing online for
articles that can help me. Thank you

Also visit my weblog; ??? ?????????? ???????????????? ? ???? 307 ??? ????????????? ??????????