3

I would like to display two pictures of different sizes next to each other, the pictures should be centered in relation to each other. But I also want the captions to be at the same height. So the caption of the small picture should not slide upwards.

My current code:

    \begin{figure}[H]
    \centering
        \begin{minipage}[c]{.4\linewidth}
            \centering
            \includegraphics[width=\linewidth]{image1.jpg}
            \caption{Caption 1}
            \label{fig:label1}
        \end{minipage}
            \hspace{.1\linewidth}
        \begin{minipage}[c]{.4\linewidth}
            \centering
            \includegraphics[width=\linewidth]{image2.jpg}
            \caption{Caption 2}
            \label{fig:label2}
        \end{minipage}
    \end{figure}

output

The picture shows the current output. As already mentioned, I would like the caption 2 to be at the same height as the caption 1 (red marking).

1
  • Welcome to tex.sx. You might try placing a "strut" in the minipage that holds the smaller shape. That would be a rule of zero width, and equal height and depth that are each half the height of the larger figure. Jun 5, 2023 at 19:16

3 Answers 3

1

No need to measure.

I set the two images in a three-column tabular, where the middle column is just used for adding horizontal space in between.

In your own document, remove the height instructions that are used here to fake different sizes (and also showframe). Fine tune the spacings and dimensions to your liking. And never use [H].

\documentclass{article}
\usepackage{graphicx,showframe}

\begin{document}

\begin{figure}[htp]
\centering
\newcommand{\localwd}{0.4\columnwidth}% local command
\setlength{\tabcolsep}{0pt}% we don't need padding

\begin{tabular}{p{\localwd} c p{\localwd}}
\multicolumn{1}{c}{%
  \begin{tabular}{c}
  \includegraphics[height=6cm,width=\localwd]{example-image}
  \end{tabular}%
} &\hspace*{0.1\columnwidth}&
\multicolumn{1}{c}{%
  \begin{tabular}{c}
  \includegraphics[height=3cm,width=\localwd]{example-image}
  \end{tabular}%
}
\\
\caption{First caption} && \caption{Second caption}
\end{tabular}

\end{figure}

\end{document}

The trick is to use c for the cells containing the images and to nest them in an inner tabular, so they will be vertically centered with respect to the other one. For the captions, the p specifier is necessary and will ensure top alignment of the captions in case they occupy more than one line.

enter image description here

1

Like this:

enter image description here

  • Your code fragment doesn't tell us anything about your document.t
  • Please, always provide MWE (Minimal Working Example), a complete small document, which reproduce your problem.
  • Your problem can be simple solved by inserting your images and captions in separate table rows. For example
    • by use of the tabularx table:
\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{tabularx}

\begin{document}
    \begin{figure}[ht]
\begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[height=55mm, width=\linewidth, valign=m]{example-image-a}
    &   \includegraphics[height=33mm,width=\linewidth, valign=m]{example-image-b}     \\
\caption{Caption 1}
    &   \caption{Caption 2}
\end{tabularx}
    \end{figure}
\end{document}
  • or by tabular:
\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{array}

\begin{document}
    \begin{figure}[ht]
\begin{tabular}{*{2}{>{\centering\arraybackslash}p{\dimexpr0.5\linewidth-2\tabcolsep}}}
\includegraphics[height=55mm, width=\linewidth, valign=m]{example-image-a}
    &   \includegraphics[height=33mm,width=\linewidth, valign=m]{example-image-b}     \\
\caption{Caption 1}
    &   \caption{Caption 2}
\end{tabular}
    \end{figure}
\end{document}

Result is the same as before.

2
  • Works great, thanks for the help. I changed your \begin{table} with a \begin{figure} so the two pictures are listed as figures, not as tables.
    – Simon
    Jun 6, 2023 at 5:57
  • @Simon, OK, now I corrected this.
    – Zarko
    Jun 6, 2023 at 6:00
0

You can align both minipages at the [b]ottom (which aligns the \captions vertically, if they are of similar length), and then raise the smaller image into position (half the difference between the two image's heights).

enter image description here

\documentclass{article}

\usepackage{graphicx}

\newsavebox{\imgbox}% To store stuff

\begin{document}

\begin{figure}
  \centering
  \begin{minipage}[b]{.4\linewidth}
    \centering
    \global\setbox\imgbox=\hbox{\includegraphics[width=\linewidth]{example-image-9x16}}% Save largest image
    \usebox\imgbox% Print image
    \caption{Caption 1}
  \end{minipage}%
  \hfill
  \begin{minipage}[b]{.4\linewidth}
    \centering
    \raisebox{\dimexpr0.5\ht\imgbox-0.5\height}{\includegraphics[width=\linewidth]{example-image-10x16}}
    \caption{Caption 2}
  \end{minipage}
\end{figure}
    
\end{document}

You must log in to answer this question.

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