latex figure with subfigures code example
Example 1: overleaf subfigures
% Side-by-side subfigures
\usepackage{subcaption}
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth]{image1}
\caption{Caption1}
\label{fig:sub1}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth]{image2}
\caption{Caption2}
\label{fig:sub2}
\end{subfigure}
\caption{Subfigures}
\label{fig:Figure1}
\end{figure}
Example 2: how to include subfigure in latex
\usepackage{subcaption}
\begin{figure}[ht]
\begin{subfigure}{.5\textwidth}
\centering
% include first image
\includegraphics[width=.8\linewidth]{image_file_name}
\caption{Put your sub-caption here}
\label{fig:sub-first}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
\centering
% include second image
\includegraphics[width=.8\linewidth]{image_file_name}
\caption{Put your sub-caption here}
\label{fig:sub-second}
\end{subfigure}
\caption{Put your caption here}
\label{fig:fig}
\end{figure}