0

I'm trying to put two images of different sizes side-by-side and the caption below the first one to fill-in blank space.

Each combinations of tb minipage option don't make the desired output.

The requirements are :

  • The two images are aligned at the top.
  • The captions is unique for both images and is written just below the first image.

In the following outputs, the images are not aligned at the top. Is it a way to adjust the minipages correctly ?

Here is a MWE :

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[top=2.5cm,bottom=2cm,left=2.6cm,right=2.6cm]{geometry}

\begin{document}
    \begin{figure}
        \centering
        \begin{minipage}[t]{0.5\linewidth}
            \centering
            \includegraphics[width=238px, height=274px]{example-image-a}
            \caption{Schémas dex expériences des aimants $A$ et $B$}
        \end{minipage}\qquad
        \begin{minipage}{0.4\linewidth}
            \centering
            \includegraphics[width=117px, height=383px]{example-image-b}
        \end{minipage}
    \end{figure}

\newpage

    \begin{figure}
        \centering
        \begin{minipage}[t]{0.5\linewidth}
            \centering
            \includegraphics[width=0.9\linewidth]{AimantAB1.png}
            \caption{Schémas dex expériences des aimants $A$ et $B$}
        \end{minipage}\qquad
        \begin{minipage}{0.4\linewidth}
            \centering
            \includegraphics[width=0.6\linewidth]{AimantAB2.png}
        \end{minipage}
    \end{figure}

\end{document}

With the corresponding output :

Example-image-output Real-image-output

1
  • The [t] and ][b] options for minipage use the first and last baselines, not the actual top and bottom. It is intended to line up text. The usual solution is to use \raisebox{-\height}{...}. Dec 26, 2019 at 15:46

2 Answers 2

2

I'm not sure, if I understood your question correctly ... like this?

enter image description here

\documentclass[11pt,a4paper]{report}
\usepackage[export]{adjustbox} % it load graphicx too
                               % used to move images' baselines at their top
\usepackage[vmargin=2.5cm, hmargin=2.6cm]{geometry}

\begin{document}
    \begin{figure}
        \centering
        \begin{minipage}[t]{0.5\linewidth}
            \centering
            \includegraphics[width=238px, height=274px,valign=t]{example-image-a}
            \caption{Schémas dex expériences des aimants $A$ et $B$}
        \end{minipage}\hfil
        \begin{minipage}[t]{0.4\linewidth}
            \centering
            \includegraphics[width=117px, height=383px,valign=t]{example-image-b}
        \end{minipage}
    \end{figure}
\end{document}
5
  • I've written the question. The goal is to align the two minipages on the same top line.
    – Piroooh
    Dec 26, 2019 at 12:37
  • This is done in my answer, however, for unknown reason loaded images is not shown. Please test my code (MWE)
    – Zarko
    Dec 26, 2019 at 12:44
  • The closing marker is not correctly set. It has to be ``` just after \end{document}
    – Piroooh
    Dec 26, 2019 at 12:48
  • @Piroooh, thank you for note. Apparently I need new glasses :-(
    – Zarko
    Dec 26, 2019 at 12:49
  • In a first try, it didn't work to set valign=t in option because i forgot to add the [export] option for adjustbox. The final result is shorter and more readable. Thanks !
    – Piroooh
    Dec 26, 2019 at 12:54
1

Please try with:

\documentclass[11pt,a4paper]{report}
\usepackage{graphicx}
\usepackage[top=2.5cm,bottom=2cm,left=2.6cm,right=2.6cm]{geometry}
\usepackage{adjustbox}

\begin{document}
    \begin{figure}
        \centering
\adjustbox{valign=t}{
        \begin{minipage}[t]{0.5\linewidth}
            \centering
            \includegraphics[width=238px, height=274px]{example-image-a}
            \caption{Schémas dex expériences des aimants $A$ et $B$}
        \end{minipage}}\qquad
\adjustbox{valign=t}{
        \begin{minipage}{0.4\linewidth}
            \centering
            \includegraphics[width=117px, height=383px]{example-image-b}
        \end{minipage}}
    \end{figure}

\end{document}

OUTPUT:

enter image description here

4
  • It fits exactly what i was looking for. Do you know if there is a way with the minipage adjustment options ? If not i'll use the adjustbox package.
    – Piroooh
    Dec 26, 2019 at 12:42
  • @Piroooh, with my answer you obtain the same result ... :-)
    – Zarko
    Dec 26, 2019 at 12:42
  • @Piroooh As Zarko advised \includegraphics[width=238px, height=274px,valign=t] also a wonderful suggestion...
    – MadyYuvi
    Dec 26, 2019 at 12:45
  • Yes, i've experimented some troubles because i forgot to add export option. So @Zarko solution is more convenient. But the two are very close. Thank you too !
    – Piroooh
    Dec 26, 2019 at 12:56

You must log in to answer this question.

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