“the j stands for Jesus”
about me | research blog | wordpress plugins | jQuery plugins

9 May, 2010

Vertical alignment of inline images in LaTeX

This is one of those things which isn’t so easy to find, so here’s my contribution.

The Problem

You’re using LaTeX, and have a small image which you want to display inline with the text (i.e. not a float). So, you use something like the following:

...indicate whether the phrase you've constructed is valid (\includegraphics{tick.png}) or not (\includegraphics{cross.png}}). To make things...

This works, but often the vertical alignment is not quite right, as shown in the images below:

Inline images, non-aligned

Zoomed (x600)

The Solution

After some searching and experimenting, I found the best solution to be using the \raisebox command with a negative value, like so:

...indicate whether the phrase you've constructed is valid (\raisebox{-1mm}{\includegraphics{tick.png}}) or not (\raisebox{-1mm}{\includegraphics{cross.png}}). To make things...

The additional code is minimal and it works perfectly (as far as I can tell). Results as below:

Inline images, properly aligned

Zoomed (x600)

22 September, 2009

LaTeX underlines in uneven positions?

Just started using LaTeX, and it annoyed me how the vertical-alignment of the \underline{} tag is not always the same, depending on whether the text ‘dips downwards’ or not (don’t know the correct term).

Anyway I found a fix, basically use \usepackage[normalem]{ulem} in your preamble, and \uline{My Text} instead of \underline{} in your normal text.

via Getting to Grips with Latex – Formatting – Latex Tutorials by Andrew Roberts @ School of Computing, University of Leeds.

16 September, 2009

Vertical Centering With CSS

A great, cut-to-the-chase article I found about vertical centering with CSS.. enjoy

In the Woods – Vertical Centering With CSS.