6
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=3cm]{Vlieger} 
    \caption{Vlieger}
    \label{fig1:}
\includegraphics[width=3cm]{Pijl}
    \caption{Pijl}
    \label{fig2:}
\end{minipage}

This is my code to put my two images next to each other. But it doesn't work... Can someone pleas help me?

  • Welcome to TeX.SE. How wide is the text block? You're restricting the minipage to have width 0.5\textwidth, while each graphic is given a width of 3cm. If 6cm exceeds 0.5\textwidth, the two graphics simply won't fit in the available space. – Mico Dec 13 '15 at 8:49
  • 1
    Incidentally, is the minipage embedded in a figure environment? The reason I ask is that you're using \caption statements, which generally don't work outside of figure and table environments. – Mico Dec 13 '15 at 8:50
13

As Mico suggest, probably you want to make a figure environment, where you can have two figures with two captions using minipages or subfigures environments with two subcaptions ans a main caption. Note that figure environments are floats, so by default they can be moved to the top or bottom of the page, or to another page, although you can influence the position of float environments.

In any case, in these environments and the images usually is better set relative lengths as \linewidth instead of absolute lengths as 3cm.

On the other hand, at least for big images, instead of \centering (and some spacer between the minipages or the subfigures) you may want these aligned with the margins, no matter its exact size. For this, use \hfill as in this minimal working example:

mwe

\documentclass{article}
\usepackage{graphicx} 
\usepackage{subcaption} %  for subfigures environments 
\begin{document}
% Side by side subfigures 
\begin{figure}
\begin{subfigure}[h]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Image A}
\end{subfigure}
\hfill
\begin{subfigure}[h]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{Image B}
\end{subfigure}%
\caption{This is a figure with two subfigures}
\end{figure}
% Side by side figures 
\begin{figure}
\begin{minipage}[c]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Image A}
\end{minipage}
\hfill
\begin{minipage}[c]{0.4\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{Image B}
\end{minipage}%
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.