# Align three images horizontally

I have three images that don't have the same size. I want to arrange them horizontally in a way that they are centered. I tried this code, it works for the positionning. But I don't know how I can add a subcaption to each image and a caption for the whole figure package like in the figure below.

   \begin{figure}[!h]
\centering
$\vcenter{\hbox{\includegraphics[height=3.5cm]{image_a}}}$
$\vcenter{\hbox{\includegraphics[height=7cm]{image_b}}}$
$\vcenter{\hbox{\includegraphics[height=7cm]{image_c}}}$
\caption{image}
\end{figure}


• Welcome to TeX.SX! The \vcenter method you found is not for images in a figure environment. Look at the subcaption package. – egreg Aug 21 '15 at 15:14
• then how I can align horizontally three images with different size. I tried with minipage but it doesn't work, it doesn't center horizontally all the images. – youssef mhiri Aug 21 '15 at 15:28

You can use the subfigure environment from the subcaption package:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=3cm,height=3.5cm]{example-image-a}
\caption{this is the first subfigure}
\end{subfigure}\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=3cm,height=7cm]{example-image-b}
\caption{this is the second subfigure}
\end{subfigure}\hfill
\begin{subfigure}{.3\textwidth}
\centering
\includegraphics[width=3cm,height=7cm]{example-image-c}
\caption{this is the third subfigure}
\end{subfigure}
\caption{image}
\end{figure}

\end{document}


The result:

• @GonzaloMedina, I just came across your answer while searching on a similar topic. I want to do the same with "beamer." But when I'm doing as you've suggested, I get "Environment subfigure undefined." – Eureka Sep 15 '17 at 20:21