# Align subfigures centrally in LyX

In LyX, I am placing 2 figures side-by-side by placing 2 subfloats inside a single float. This allows me to have individual captions for each subfloat and hence, each sub-figure. My problem is that the 2 figures are different sizes and are not aligned vertically. One figure is taller (longer) than the other and, as they are both aligned to the bottom of the float, the resulting output file doesn't look quite right.

I would like to align the side-by-side figures along their centerlines. Is it possible to do this, so as some whitespace will exist above and below both figures? Alternatively, is it possible to simply move the smaller figure upwards in a vertical direction from the bottom so that it lies somewhat centrally, relative to the other figure? I would prefer one of these options as opposed to messing about with resizing figures.

I have tried using various formatting tools such as Vertical Spaces to move the smaller figure upwards but none of these seem to be working. Any assistance on this matter would be appreciated as I have done numerous searches but the only available solutions I could find was to use minipages and vertical spaces. However, using minipages looses the captions in the sub-figures.

This is straight-forward in LaTeX. The idea would be to save the larger image in a box. Once this is done, you can measure it's height and move the smaller image up by some distance relative to the larger one.

In terms of LyX you can follow these instructions:

1. Insert the following in your Document > Settings... > LaTeX Preamble:

``````\newsavebox{\savedimage}
\newcommand{\saveimageheight}[2][]{%
\savebox{\savedimage}{\includegraphics[#1]{#2}}}
\newcommand{\raiseimage}[2][]{%
\raisebox{.5\dimexpr\ht\savedimage-\height}{%
\includegraphics[#1]{#2}}}%
``````

The above creates two macros: `\saveimageheight[<options>]{<image>}` that you should use to store the larger of the two images. Use `[<options>]` that you would normally specify with the original larger image.

2. Place `\saveimageheight[<options>]{<image>}` in your document before the smaller of the two images.

3. Use `\raiseimage[<options>]{<image>}` to place the smaller image.

This is what the code would look like in LyX:

Expected output:

• Thanks alot for the detailed response, exactly what I was looking for! Cheers – Sanka Jan 6 '15 at 14:16

There is a pure LyX way without ERT's. It's based on Werner's answer, except requires adding some `minipage`s:

• Place each sub-float inside a `Box (minipage)` set to have
• Vertical Content Alignment of `Middle`
• Vertical Box Alignment of `Bottom`
• Fixed height (probably greater than 200 as in your example)
• Inside each sub-float place another `Box (minipage)` also set to have Vertical Box Alignment of `Bottom`

In my example I only hard-coded the size of my images to the proportions you suggested (I didn't want to manufacture them for this example).