3

I have a problem with \minipage alignment: I want to place two images side by side with a top alignment, so I used this code:

    \begin{figure}[!h]
\begin{minipage}[t]{0.5\linewidth}
  \includegraphics[width=1\linewidth]{...}
  \caption*{}
  \label{}
\end{minipage}
\hfill
\begin{minipage}[t]{0.4\linewidth}
  \includegraphics[width=1\linewidth]{...}
  \caption*{}
  \label{}
\end{minipage}
\end{figure}

Here is the result:

enter image description here

My goal is to obtain this kind of alignment: enter image description here

Then I have to add other images to the page, in order to obtain this layout: enter image description here

I googled and tryed many solutions, but no one gave me the desired result. Thank you in advance.

EDIT: I resolved with the solution proposed by @Jesse, using valign=T instead of valign=T in order to obtain a perfect alignment. To put the images on the top of the page, I just added \newpage before the images.

Thanks to all.

qwertxyz
  • 542

1 Answers1

4

This is a possible solution, via adjustbox package where valign=t and valing=c can be used.

enter image description here

Code

\documentclass[]{article}
\usepackage[paper size={20cm,10cm}]{geometry}
\usepackage[export]{adjustbox}


\begin{document}

\begin{figure}[!h]
\begin{minipage}[t]{0.5\linewidth}
  \includegraphics[valign=t,width=1\linewidth]{example-image-a}
  \caption*{}
  \label{}
\end{minipage}
\hfill
\begin{minipage}[t]{0.4\linewidth}
  \includegraphics[valign=t,width=1\linewidth]{example-image-a}
  \caption*{}
  \label{}
\end{minipage}
\end{figure}
\end{document}
Jesse
  • 29,686
  • That worked! However the images remain stuck at the middle of the page (I want them to go up) and the top margin is not perfectly aligned. Thank you. – qwertxyz Jun 08 '14 at 15:30
  • I have managed to obtain a perfect alignment with valign=T, to put the images on the top of the new page I just added \newpage. Thanks you for your solution and thanks to @cmhughes for the help. – qwertxyz Jun 08 '14 at 15:35
  • Don't quite follow you. They are on the top, are they not? – Jesse Jun 08 '14 at 15:40
  • They are now on top of the page after adding \newpage (before they are stuck in the middle, see image 1). I obtained a perfect vertical alignment with valign=T, because with valign=t (although the images are correctly aligned on top) it persist a little displacement between the two images. – qwertxyz Jun 08 '14 at 15:46
  • OK, I see. OP only has your partial code, not MWE. My result shows they are on the top after using showframe in the geometry. – Jesse Jun 08 '14 at 15:52