45

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}
epsilon8
  • 5,961

4 Answers4

49

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.

Werner
  • 603,163
34

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).

Martin Thoma
  • 18,799
28

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}
Tobi
  • 56,353
6

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}
gcedo
  • 2,699
  • 23
  • 20