[Tex/LaTex] Captions of figures in minipage

captionsfloatsminipage

I am trying to have two image on the same line. I found some solutions online which seems to work pretty well, and i've decided to use this one:

\begin{figure}[!ht]
\begin{minipage}[c]{8cm}
    \centering
    \includegraphics[width =\textwidth]{money_spend_on_cloud.png}
    \caption{money spend on cloud}
\end{minipage}
\hfill
\begin{minipage}[c]{8cm}
    \centering      
    \includegraphics[width=\textwidth]{WB-graph.jpg}
    \caption{Cloud storage}
\end{minipage}
\end{figure}

The two figures are on the same page. However, i have only one caption, which takes the whole page (it's not limited to its minipage) and i don't understand why. It seems that the caption of first picture is somehow "under" the second caption and thus not visible, but since caption are on separate minipages it shouldn't be the case.

Plus, this code is used on many example and the captions are well placed :/

Can someone help me solve this? Here is the problem:
Caption problem

EDIT: as it works well on online example, i guessed it cames from my document class. I was rigth. I have those lines in my document class:

\newlength{\float@capnamewd}   % neu
\newlength{\float@cparwidth}   % neu
\newsavebox{\float@capnamebox} % neu
\renewcommand\floatc@ruled[2]{%
\savebox{\float@capnamebox}{\@fs@cfont #1\hspace*{1.5ex}}
\settowidth{\float@capnamewd}{\usebox{\float@capnamebox}}%
\setlength{\float@cparwidth}{\hsize}%
\addtolength{\float@cparwidth}{-1.0\float@capnamewd}%
\usebox{\float@capnamebox}\parbox[t]{\float@cparwidth}{#2\par}}
\renewcommand\fs@ruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled
\def\@fs@pre{}%
\def\@fs@post{\kern2.5pt\hrule height.1pt depth0pt\relax}%
\def\@fs@mid{\kern2pt\hrule height.1pt depth0pt \kern2.5pt}%
\def\@fs@cfont{\captionfont\bfseries}
\let\@fs@iftopcapt\iffalse}
\floatstyle{ruled}
\restylefloat{figure}
\restylefloat{table}

I have no idea what it means, but it's obviously about figures and captions. And when i put it as commentary, then my code for figures works well. This is what i get (and exactly what i wanted):

enter image description here

The caption format is not the same, but i don't care at all.
However, i would like to understand what those lines in my document class are doing.
Can someone explain me those lines? Maybe i don't have to put everything in commentary…

EDIT: so, trying to see what exactly in my wissdoc was problematic, i ended up putting only the line

\restylefloat{figure}

in commentary. So if i thought that all the lines before are defining a new float style, and then this line apply it to the figures. But this new float style is bad for me.
However, when i put all the lines but this one in commentary, i still have the problem. The caption have the same format that in my second picture, but there's just the second one placed like in my first picture.
I don't get it.

Best Answer

First, I used floatrow to emulate your document class.

\documentclass{article}
\usepackage{floatrow}
\floatsetup{style=ruled,capposition=bottom}
\usepackage{graphicx}

\begin{document}
\begin{figure}[!ht]
\begin{minipage}[c]{0.45\textwidth}
    \centering
    \includegraphics[width =\textwidth]{example-image-a}
    \caption{money spend on cloud}
\end{minipage}
\hfill
\begin{minipage}[c]{0.45\textwidth}
    \centering      
    \includegraphics[width=\textwidth]{example-image-b}
    \caption{Cloud storage}
\end{minipage}
\end{figure}

\end{document}

problem

Then I used paracol to achieve the desired effect while maintaining the intention of the anal retentive who designed the thing. Unlike multicol, paracol supports floats. You might want to use \afterpage (afterpage package) if this causes a page break.

\documentclass{article}
\usepackage{floatrow}
\floatsetup{style=ruled,capposition=bottom}
\usepackage{graphicx}
\usepackage{paracol}% support floats
\globalcounter{figure}

\begin{document}
\begin{paracol}{2}
\begin{figure}
    \centering
    \includegraphics[width =\columnwidth]{example-image-a}
    \caption{money spend on cloud}
\end{figure}
\switchcolumn
\begin{figure}
    \centering      
    \includegraphics[width=\columnwidth]{example-image-b}
    \caption{Cloud storage}
\end{figure}
\end{paracol}

\end{document}

solution

Related Question