“the j stands for Jug”
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)


  1. Thanx for this, helped me with my inline images 🙂

    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

  7. Thanks for a tip. This helped me in my LaTeX Beamer presentation.

    Comment by Mark — 11 May, 2012 @ 12:19 pm

  8. Perfect–just what I was looking for.

    Comment by Robin K — 7 June, 2012 @ 5:06 pm

  9. Thank you! The code works really well.

    Comment by GeMir — 22 June, 2013 @ 2:21 pm

  10. Use the adjustbox package: http://tex.stackexchange.com/questions/101858/make-two-figures-aligned-at-top
    With this you can specify the vertical adjustment while using \includegraphics

    Comment by Ano Nym — 29 July, 2013 @ 4:31 pm

  11. Thanks so much for this, I have been looking for this solution for hours!

    Comment by Susan J — 22 April, 2015 @ 12:41 am

Leave a comment