I found this answer which does exactly what I want except the fact that I can't use a caption for my figures:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
I want two figures side by side. The problem I usually have is that they are in different sizes and that it takes alot of time to scale them manually to the same height, use the whole text width and still keep the ratio.
I tried to use this command, but it wont work as I get the error "Missing \endgroup inserted".
\resizebox{\textwidth}{!}{%
\begin{figure}[H]
\includegraphics[height=4cm,fbox]{testfigure_1.jpg}%
\caption{My figure 1}
\end{figure}
\begin{figure}[H]
\includegraphics[height=4cm,fbox]{testfigure_2.jpg}%
\caption{My figure 1}
\end{figure}
}
I have realised that I of some reason cannot put an figure enviroment within resizebox. Still I cannot solve this.
I don't know if this matter to your answers but in my code I use this to center all captions for my figures: \usepackage[justification=centering]{caption}