[Tex/LaTex] Using minipage with subfigure didn’t produce side by side figures

minipagesubfloats

As per this, I tried using \minipage with my \subfigure, however to no avail. (My figures are still stacked vertically)
I even tried changing scale to width=0.5\textwidth

What did I do wrong?

Brief working example:

Also uploaded here as a .zip file.

Sorry, I really don't know how to format stuff on here. So it looks messy.

\documentclass[a4paper,10pt]{article}
\usepackage{setspace}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{eps2pdf}
\usepackage{subfigure}
\usepackage{float}
\usepackage[super,numbers,sort&compress]{natbib}
\usepackage{color}
% \usepackage{underscore}
\usepackage{grrfile}
\usepackage{placeins}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}
\renewcommand{\thefootnote}{\alph{footnote}}
\usepackage[paper=letterpaper,left=1.0in,right=1.0in,top=0.25in,bottom=1.0in,]{geometry}




\begin{document}



\begin{figure}[ht]
\centering

\begin{minipage}{0.45\textwidth}
\begin{subfigure}[Initial condition]{
   \includegraphics[scale =0.25] {./pngs/profile_L_3lambda_max_1wl_0.png}
   \label{fig:subfig1}
 }
\end{subfigure}
\end{minipage} 


\begin{minipage}{0.45\textwidth}
 \begin{subfigure}[DFT]{
   \includegraphics[scale =0.25] {./pngs/profile_L_3lambda_max_1wl_dft_0.png}
   \label{fig:subfig2}
 }\end{subfigure}
\end{minipage}



\begin{minipage}{0.45\textwidth}
 \begin{subfigure}[DFT (corner)]{
   \includegraphics[scale =0.25] {./pngs/profile_L_3lambda_max_1wl_dft_0_X.png}
   \label{fig:subfig3}
 }\end{subfigure}
\end{minipage}


\label{myfigure}
\caption{Initial condition, $L=3\lambda_{max}, \text{k}=1, G=0.333,S=100, M=35.1, \text{Pr=7.02}, E=0, Ra=0$}
\end{figure}




\begin{figure}
\centering

\begin{subfigure}[Initial condition]{
   \includegraphics[scale =0.25] {./pngs/profile_L_3lambda_max_1wl_Rup.png}
   \label{fig:subfig4}
 }\quad
\end{subfigure}

 \begin{subfigure}[DFT]{
   \includegraphics[scale =0.25] {./pngs/profile_L_3lambda_max_1wl_dft_Rup.png}
   \label{fig:subfig5}
 }\end{subfigure} 

\label{myfigure}
\caption{Rupture condition, , $L=3\lambda_{max}, \text{k}=1, G=0.333,S=100, M=35.1, \text{Pr=7.02}, E=0, Ra=0$}
\end{figure}

\end{document}

Best Answer

If, for some reason, you can't use another package but the obslote subfigure package, here's one way to achieve what you want; basically, don't leave blank lines between subfigure environment (those blank lines are \par commands ending a paragraph); also, instead of using scale=<value> it could be safer to use width=<length> so that you can guarantee that the total width for the three images won't surpass the \textwidth (of course, if you can guarantee the condition using scale, then feel free to use that option instead); try not to leave spurious blank spaces (your code has some of those too which I removed using % at the end of some lines):

\documentclass[a4paper,10pt]{article}
\usepackage[demo]{graphicx}
\usepackage{subfigure}
\usepackage{amsmath}
\usepackage{grrfile}
\usepackage[paper=letterpaper,left=1.0in,right=1.0in,top=0.25in,bottom=1.0in,]{geometry}

\begin{document}

\begin{figure}[ht]
\centering
\begin{subfigure}[Initial condition]{\includegraphics[width=.3\linewidth] {./pngs/profile_L_3lambda_max_1wl_0.png}
   \label{fig:subfig1}
 }%
\end{subfigure}\hfill
 \begin{subfigure}[DFT]{\includegraphics[width=.3\linewidth]{./pngs/profile_L_3lambda_max_1wl_dft_0.png}
   \label{fig:subfig2}
 }%
\end{subfigure}\hfill
 \begin{subfigure}[DFT (corner)]{\includegraphics[width=.3\linewidth]{./pngs/profile_L_3lambda_max_1wl_dft_0_X.png}
   \label{fig:subfig3}
 }%
\end{subfigure}%
\caption{Initial condition, $L=3\lambda_{max}, \text{k}=1, G=0.333,S=100, M=35.1, \text{Pr=7.02}, E=0, Ra=0$}
\label{fig:myfigure}
\end{figure}

\end{document}

enter image description here

For the example, I removed some of the packages that were not essential for the solution.

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.