28

I have two images. How do I align them side by side and scale them so that both of them together occupy the whole horizontal space in a beamer presentation?

\begin{frame}
\frametitle{Inconsistency}
\begin{itemize}
\item 
\begin{center}
\includegraphics[scale=0.3]{peer}
\includegraphics[scale=0.3]{peer-inconsistent}  
\end{center}
\end{itemize}
\end{frame}
33

If vertical size do not matter, then you could use

\includegraphics[width=<X>\textwidth]{<first image>}%
\includegraphics[width=<1-X>\textwidth]{<second image>}

Here <X> denotes a number in (0,1), while <1-X> denotes its complement in the interval (0,1). Note the % to remove any space between the images. For equally-sized images, <X>=<1-X>=.5. Using only width as the scaling dimension will scale the height proportionally, maintaining the aspect ratio.

If vertical size does matter, you can also specify the height.

  • 1
    why do I get Illegal unit of measure (pt inserted) error? for \includegraphics[width=0.5\textwidth]{peer} – zcqwevb Apr 30 '12 at 21:13
  • @user494461: I don't know. You need to provide more context (either in comment, but preferably by editing your original question). – Werner Apr 30 '12 at 21:23
  • @user494461: This should work perfectly. Could you check it again. If the issue is still there, please post a full compilable example which causes the issue. – Martin Scharrer Apr 30 '12 at 22:38
  • That works fine for me. However I want to add captions under the images. So I have to use some figure environnement for which your solution does not work. I find minicaption able to do that in beamer. The only problem is that you have two width: the width of the minifigure and the width of the image in the figure so tweaking is needed. – Gabriel Devillers Sep 19 '17 at 20:15
21

Just use width=0.5\textwidth instead of scale=3. The width option will scale an image to match the given width while keeping the aspect ratio.

To get a little white space between them you may use something like this.

\begin{figure}
   \includegraphics[width=0.475\textwidth]{peer}
   \hfill
   \includegraphics[width=0.475\textwidth]{peer-inconsistent}
\end{figure}
14

If you want to add captions to it, I suggest:

\begin{frame}{Pixelweise Segmentierung}
    \begin{figure}[ht]
        \begin{minipage}[b]{0.45\linewidth}
            \centering
            \includegraphics[width=\textwidth]{a.png}
            \caption{Label for a}
            \label{fig:a}
        \end{minipage}
        \hspace{0.5cm}
        \begin{minipage}[b]{0.45\linewidth}
            \centering
            \includegraphics[width=\textwidth]{b.png}
            \caption{Label for b}
            \label{fig:b}
        \end{minipage}
    \end{figure}
\end{frame}

Additionally, you might want to add the line

\setbeamertemplate{caption}{\raggedright\insertcaption\par}

to prevent the prefix "Figure" (source).

3

You can use the columns enviroment:

\begin{frame}
\frametitle{Incosistency}
\begin{columns}[c]
    \column{.5\textwidth}
        \begin{center}
            \includegraphics[scale=0.3]{peer}
        \end{center}
    \column{.5\texwidth}
        \begin{center}
             \includegraphics[scale=0.3]{peer-inconsistent} 
        \end{center}
\end{columns}

\end{frame}
  • This won't scale the images to the required size. – Martin Scharrer Apr 30 '12 at 22:37
  • I had wrongly interpreted the question, my bad. – gcedo May 1 '12 at 12:04

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.