How to align two images side by side and to scale them automatically to use whole slide?
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
.
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}
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).