Vertical alignment of graphics

If graphics or graphics and text had to be set side-by-side they would often be placed inside minipage environments. This usually works fine if the minipages should be bottom-aligned. A frequently asked question is how to get top alignment, like here on mrunix.de and here on matheplanet.com. A first approach could be to use t as optional positioning argument of the minipage environment. Here’s a compilable example, showing that graphics would stay bottom-aligned that way, used for a fix:

\documentclass{article} \usepackage[demo]{graphicx} \begin{document} \begin{figure}[ht] \fbox{\begin{minipage}[t]{150pt} \includegraphics[height=100pt,width=150pt]{test} \end{minipage}} \hfill \fbox{\begin{minipage}[t]{150pt} \includegraphics[height=60pt,width=150pt]{test} \end{minipage}} \end{figure} \end{document}

I’ve used \fbox additionally to visualize the minipages. You may notice that it’s compilable even without the image file, that’s achieved by using demo as option for graphicx.

The reason is that \includegraphics sets the baseline to the bottom. A quick fix is just to insert \vspace{0pt} right before each \includegraphics command, this way the reference point will be the top and both images will be placed top-aligned now.

You could use the same approach if you want to place graphics inside \parbox or inside table cells top-aligned.

18. October 2008 by stefan