# Convert two separate side by side figures into two subfigures

I have two figures that are side by side but I want to convert them into subfigures so that they come out as Figure 1a and Figure 1b instead of Figure 1 and Figure 2.

\begin{figure}
\centering
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=1.04\textwidth]{Figures/figure1.png} % first figure itself
\caption{first figure}
\end{minipage}\hfill
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=1.04\textwidth]{Figures/figure2.png} % second figure itself
\caption{second figure}
\end{minipage}
\end{figure}


with use of the packagesubcaption is simple. just replace minipage with subfigure:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{Figures/figure1.png} % first figure itself
\caption{first figure}
\label{fig:aubfig a}
\end{subfigure}\hfill
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{Figures/figure2.png} % second figure itself
\caption{second figure}
\label{fig:aubfig b}
\end{subfigure}
\caption{My sub-figures}
\label{fig:my subfigures}
\end{figure}
\end{document}


note: it is not good idea to prescribe image width bigger from space in minipage or in subfigure.