[Tex/LaTex] Add four images on a beamer frame with caption

beamercaptions

Can someone tell me how to put captions in the figure solution provided by @Gonzalo at Add four images on a beamer frame

Best Answer

Gonzalo Medina said in the linked question that you don't need the figure environment if there are not captions. But inversely, you can use this environment if you want captions:

wwe

\documentclass{beamer}
%just to simplifly the body of the document
\def\img#1{%
\begin{figure}
\includegraphics[width=\linewidth, height=.2\textheight, keepaspectratio]% 
{example-image-#1} 
\caption{Caption of \MakeUppercase #1}
\end{figure}}

\begin{document}
\begin{frame}{4 images}
\begin{columns}[t]
\column{.5\textwidth}
\img{a}\img{b}
\column{.5\textwidth}
\img{1x1}\img{c}
\end{columns}
\end{frame}
\end{document}

If you are not happy with float behavior in Beamer, alternatively you can use the \figcaption of the cattdef package (or \captionof{figure}{...} of caption package, but not inside macro as in this example):

mwe2

\documentclass{beamer}
\usepackage{captdef}
%just to simplifly the body of the document
\newcommand\img[1]{%
\centering
\includegraphics[width=\linewidth, height=.2\textheight, keepaspectratio]%
{example-image-#1}\par\figcaption{Caption of \MakeUppercase #1}
}

\begin{document}
\begin{frame}{4 images}
\begin{columns}[t]
\column{.5\textwidth}
\img{a}\img{b}
\column{.5\textwidth}
\img{1x1}\img{c}
\end{columns}
\end{frame}
\end{document}