Beamer support seems to be broken
Using https://www.overleaf.com/learn/latex/Positioning_images_and_tables#Multiple_images_in_one_figure in a beamer document results in the following error message if the caption package is loaded:
"! You can't use `\unskip' in vertical mode."
\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}
\usepackage{subcaption}
\begin{document}
%\begin{frame}
Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque...
\begin{figure}[h]
\centering
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=0.9\linewidth, height=2cm]{overleaf-logo}
\caption{Caption1}
\label{fig:subim1}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=0.9\linewidth, height=2cm]{mesh}
\caption{Caption 2}
\label{fig:subim2}
\end{subfigure}
\caption{Caption for this figure with two images}
\label{fig:image2}
\end{figure}
Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper.
%\end{frame}
\end{document}
Edited by Axel Sommerfeldt