46

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}

4 Answers 4

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.

6
  • 2
    why do I get Illegal unit of measure (pt inserted) error? for \includegraphics[width=0.5\textwidth]{peer}
    – epsilon8
    Commented Apr 30, 2012 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
    Commented Apr 30, 2012 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. Commented Apr 30, 2012 at 22:38
  • 1
    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. Commented Sep 19, 2017 at 20:15
  • +1 for the % at the line end. This one gets me again and again. Commented Oct 12, 2020 at 13:25
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).

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}
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}
3
  • 2
    This won't scale the images to the required size. Commented Apr 30, 2012 at 22:37
  • I had wrongly interpreted the question, my bad.
    – gcedo
    Commented May 1, 2012 at 12:04
  • 1
    There's a small typo. Replace 'texwidth' by 'textwidth' ;-) Commented Jan 23, 2021 at 9:06

You must log in to answer this question.

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