14

I have an figure* environment with the following

\begin{figure*}
    \centerline {
    \subfloat[1]{...}
    \subfloat[2]{...}
    }
\end{figure*}

The images are different heights. How can I vertically align them? i.e. so the centre of each image is next to each other:

_____
|    |     _____  
|    |  _  |    |
|    |     |____|
|____|

     Fig. 1
15

There are two different scenarios, independent of whether you use the figure or figure* environment (or any other float for that matter). The first allows you to move the entire label with the image, while the second keeps the image label at the same level as the other one:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{subfig}% http://ctan.org/pkg/subfig
\begin{document}
\newsavebox{\myimage}
\begin{figure}
  \centering
  \savebox{\myimage}{\hbox{\rule{150pt}{150pt}}}% Store largest image
  \subfloat[First]{\usebox{\myimage}} \quad
  \raisebox{\dimexpr.5\ht\myimage-.5\height\relax}{\subfloat[Second]{\rule{100pt}{100pt}}}
  \caption{This is a figure.}
\end{figure}

\begin{figure}
  \centering
  \savebox{\myimage}{\hbox{\rule{150pt}{150pt}}}% Store largest image
  \subfloat[First]{\usebox{\myimage}} \quad
  \subfloat[Second]{\raisebox{\dimexpr.5\ht\myimage-.5\height\relax}{\rule{100pt}{100pt}}}
  \caption{This is a figure.}
\end{figure}
\end{document}

The idea is to store the largest image in a box (\myimage). Then you raise the smaller image (50% of the largest box) - (50% of the smaller box) or, in LaTeX terms,

\dimexpr.5\ht\myimage-.5\height\relax

.5\ht\myimage refers to 50% of the height of \myimage, while .5\height refers to 50% of the height of the current box (contained within the \raisebox command). You first have to "create" a box using \newsavebox, and assign something to it using \savebox.

In the example above, graphicx was not required since no images were included (I used \rule{<width>}{<height>}). However, you'll need to use it if you include images.

Other options might also be possible via floatrow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.