# Subfigures side by side with captions using minipage instead of subfigures

I tried to insert side by side figures making a minipage instead of subfigures. The captions of the two figures are not aligned and are numbered ina wrong way.

I'd like to align captions and number the figures (a), (b) and the total figure fig. n with n the correct number (1 if the fig is the first in the document ecc).

\documentclass{article}
\usepackage{mwe}

\begin{document}

\begin{figure}[h]
\centering
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[scale=0.3]{fig2a}
\caption{Modello compartimentale mammellare (o mammillare).}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[scale=0.3]{fig2b}
\caption{Modello compartimentale catenario.}
\end{minipage}
\caption{Principali topologie dei modelli compartimentali.}
\end{figure}

\end{document}


Thank you very much in advance.

• If the subcaption package is loaded, a subfigure environment is nothing but a minipage environment with some minimal functionality to "number" the caption as a, b, c, etc instead of 1, 2, 3, etc. The subfigure environments take the same positioning specifiers as  minipage environments do. So, why is it that you don't what to use subfigure environments? – Mico Dec 6 '17 at 10:54
• Hello @Mico, my goal is to learn to do the same thing in different ways. – Gennaro Arguzzi Dec 6 '17 at 10:57
• Well, if you don't want to use subfigure environments but still generate captions that are numbered a, b, c, etc (or whatever else you do), you basically have to "reinvent the wheel" and come up with caption-related macros -- a problem that's been solved by the writer(s) of the subcaption package... – Mico Dec 6 '17 at 11:00
• Thanks for your precious explanation @Mico, now it is clear! – Gennaro Arguzzi Dec 6 '17 at 11:09

To repeat what was already stated in the comments: A subfigure environment is already a minipage environment -- just one with some added capabilities related to creating captions.

Here's how I'd rewrite your code, mainly loading the subcaption package and using two subfigure environments.

\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real doc.
\usepackage{subcaption}
\usepackage[italian]{babel}

\begin{document}

\begin{figure}
\begin{subfigure}[t]{0.475\textwidth}
\includegraphics[width=\textwidth]{fig2a}
\caption{Modello compartimentale mammellare (o mammillare).}
\label{fig-a}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.475\textwidth}
\includegraphics[width=\textwidth]{fig2b}
\caption{Modello compartimentale catenario.}
\label{fig-b}
\end{subfigure}
\caption{Principali topologie dei modelli compartimentali.}
\label{fig:main}
\end{figure}

\end{document}

• your answer is impeccable! Thank you for your efforts! – Gennaro Arguzzi Dec 6 '17 at 15:52
• @GennaroArguzzi - You're most welcome! – Mico Dec 6 '17 at 16:03