[Tex/LaTex] Two figures side by side caption issue

captionsminipage

I have searched around for two hours without luck. So I hope someone can help me this issue.
Basically I want to place two different figures side by side to save space in my report. So I don't want subfigures with common caption here.

I tried using minipage as follows:

\begin{figure}[ht]
\begin{minipage}[b]{.5\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test1.png}
\caption{This is caption of test1.}
\label{fig:HOG_resolution}
\end{minipage}
\hfill
\begin{minipage}[b]{.4\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test2.png}
\caption{This caption for test 2 is longer than the caption in test1. It should spread on two lines}
\label{fig:block_overlap}
\end{minipage}
\end{figure}

My figures show up fine, except for the captions. The first caption is missing, the second one shows up at the position of the first one.
enter image description here

My preamble is as follows:

\documentclass[11pt]{report}

\usepackage{graphics}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subfig}
\usepackage{float}

\usepackage{multirow}
\restylefloat{figure}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.75cm, right=2.75cm]{geometry}

\usepackage[titles,subfigure]{tocloft}

\usepackage[bookmarks]{hyperref}

\lstnewenvironment{code}[1][]
  {\minipage{\linewidth} 
   \lstset{#1}}
  {\endminipage}

\newcommand{\myvec}[1]{\bf{#1}}
\newcommand{\mymtrx}[1]{\bf{#1}}

I also tried \captionof instead of \caption (u probably see I put \usepackage{caption} at my preamble) but it doesn't work. I also use package subfig because I want to create subfigures side by side as well, and I dont have problem with that.

Best Answer

This code demonstrates the problem:

\documentclass{report}

\usepackage[demo]{graphicx}
\usepackage{float}

\restylefloat{figure}

\begin{document}

\begin{figure}[ht]
\begin{minipage}[b]{.5\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test1.png}
\caption{This is caption of test1.}
\end{minipage}
\hfill
\begin{minipage}[b]{.4\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test2.png}
\caption{This caption for test 2 is longer than the caption in test1. It should spread on two lines}
\end{minipage}
\end{figure}

\end{document}

The rest of the preamble seems not to be implicated.

I am not sure what else you want but using the starred version of \restylefloat apparently tells the package to leave the captions alone and this gets you two captions rather than one:

\documentclass{report}

\usepackage[demo]{graphicx}
\usepackage{float}

\restylefloat*{figure}

\begin{document}

\begin{figure}[ht]
\begin{minipage}[b]{.5\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test1.png}
\caption{This is caption of test1.}
\end{minipage}
\hfill
\begin{minipage}[b]{.4\textwidth}
\centering
\includegraphics[width=1\textwidth]{figs/test2.png}
\caption{This caption for test 2 is longer than the caption in test1. It should spread on two lines}
\end{minipage}
\end{figure}

\end{document}

two captions