“the j stands for Justiceable”
about me | wordpress plugins | jQuery plugins

9 May, 2010

Vertical alignment of inline images in LaTeX

Filed under: LaTeX,Useful — Tags: , , , , , — John @ 12:05 pm

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)

6 Comments »

  1. Thanx for this, helped me with my inline images :)
    Ladislav

    Comment by Ladislav Klinc — 21 May, 2010 @ 9:19 am

  2. Ditto. Thanks so much!

    Comment by Andrew Pennebaker — 3 September, 2010 @ 10:20 pm

  3. Many thanks for this. Was driving me nuts.

    Comment by Barry Gausden — 25 November, 2010 @ 3:49 am

  4. it works!! thanks!!

    Comment by Rui Pedrosa — 1 December, 2010 @ 5:28 pm

  5. Thanks for this little hack.

    Comment by Alexandra — 15 February, 2011 @ 6:06 am

  6. Just wanted to say thanks. This helped a lot.

    Comment by Marcelo — 25 August, 2011 @ 9:01 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment