5

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}}}$
  \qquad
  $\vcenter{\hbox{\includegraphics[height=7cm]{image_b}}}$
  \qquad
  $\vcenter{\hbox{\includegraphics[height=7cm]{image_c}}}$
\caption{image}
\end{figure}

enter image description here

2
  • Welcome to TeX.SX! The \vcenter method you found is not for images in a figure environment. Look at the subcaption package.
    – egreg
    Commented Aug 21, 2015 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. Commented Aug 21, 2015 at 15:28

1 Answer 1

8

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:

enter image description here

2
  • @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
    Commented Sep 15, 2017 at 20:21
  • How can I do the same but aligning the captions at the bottom while the images are center-aligned as in the figure of this answer?
    – el_maxx
    Commented Sep 15, 2022 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .