# add multilevel caption in figures

I am working on overleaf, i need to place images caption like this (highlighted with red pen and blue pen in figure below) separate caption for every image then one caption for two images. The code is given below this code only place captions for two separate images

    \documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{multicol}
\usepackage{lipsum}

\usepackage{subcaption}

\newsavebox{\shortpagebox}
\newsavebox{\shortpagefigure}
\begin{document}
\begin{figure*}
\centering
\setkeys{Gin}{width=0.48\linewidth} % <---
\begin{minipage}{0.48\linewidth}
\includegraphics{example-image}\hfil
\includegraphics{example-image}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:first}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
\includegraphics{example-image}\hfil
\includegraphics{example-image}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:second}
\end{minipage}

\bigskip
\begin{minipage}{0.48\linewidth}
\includegraphics{example-image}\hfil
\includegraphics{example-image}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:third}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
\includegraphics{example-image}\hfil
\includegraphics{example-image}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:fourth}
\end{minipage}
\end{figure*}
\end{document}

• have you tried using \subcaption{...} inside each minipage, and \caption{...} for the "overall" caption before \end{figure*}? Aug 16 '21 at 4:35
• According to the IEEEtran manual: "However, most IEEE authors/journals do not employ subfigure captions, but instead reference/describe all of the subfigures (a), (b), etc., within the main caption." Aug 16 '21 at 19:03

Since you load the subcaption package, you could use its subfigure environment machinery -- a subfigure is, basically, a minipage environment that's been told what to do if it encounters a \caption directive in its scope -- to achieve your formatting objective.

• You'll get some warning messages as the caption and subcaption packages aren't fully aware of what the IEEEtran document class can and cannot do. You may ignore these warning messages.

• The output of the approach proposed here is quite similar to that of Zarko's answer, which isn't surprising as both answers employ the subcaption package. A possibly meaningful difference in the approaches may be that that using subfigure environments rather than \subfloat macros provides a touch more flexibility in terms of vertical positioning of the graphs.

\documentclass{IEEEtran}
\usepackage{graphicx}
\usepackage[skip=0.33\baselineskip]{subcaption}
\begin{document}
\setcounter{figure}{7} % just for this example

\begin{figure*}
\begin{minipage}[t]{\columnwidth}% 1st minipage
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{CNN with \dots}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{LTSM with \dots}
\end{subfigure}
\caption{The distribution of score}
\label{fig:first}
\end{minipage}%
\hfill
\begin{minipage}[t]{\columnwidth}% 2nd minipage
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Rounds vs.\ accuracy}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Payment $p$ and score with $N$}
\end{subfigure}
\caption{Training speed and payment with parameter $N$}
\label{fig:second}
\end{minipage}

\bigskip\medskip
\begin{minipage}[t]{\columnwidth}% 3rd minipage
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Rounds vs.\ accuracy}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Payment $p$ and score with $K$}
\end{subfigure}
\caption{Training speed and payment with parameter $K$}
\label{fig:third}
\end{minipage}%
\hfill
\begin{minipage}[t]{\columnwidth}% 4th minipage
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Training speed with $p$}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.475\linewidth}%
\includegraphics[width=\linewidth]{example-image}
\caption{Proportion of selected node}
\end{subfigure}
\caption{Performance impact of parameter $\psi$}
\label{fig:fourth}
\end{minipage}
\end{figure*}

\end{document}

• If you want to make it look like normal figures, use \vskip\floatsep between rows. Aug 17 '21 at 19:39
• @JohnKormylo - Thanks. In my opinion, \vskip\floatsep doesn't insert quite enough whitespace for the material at hand -- at least not if the IEEEtran document class is in use. Of course, others may disagree. The skips \floatsep, \bigskipamount, and \medskipamount work out to 10.2pt plus 2.4pt minus 2.4pt, 12pt plus 4pt minus 4pt, and 6pt plus 2pt minus 2pt.
– Mico
Aug 17 '21 at 20:20

Each image insert in \subfloat environment (also defined in the subcaption package. In answer is assumed that all images in figure have equal which, which consequently can be defined by key Gin for all of them in figure.

\documentclass{IEEEtran}
\usepackage{graphicx}

\usepackage{subcaption}

\begin{document}
\begin{figure*}
\centering
\setkeys{Gin}{width=0.48\linewidth} % <---
\begin{minipage}{0.48\linewidth}
\subfloat[CNN with CIFAR-10]{\includegraphics{example-image}}\hfill
\subfloat[LSTM with HPNews]{ \includegraphics{example-image}}

\caption{The distribution of score}
\label{fig:first}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
\subfloat[caption 2a]{\includegraphics{example-image}}\hfill
\subfloat[caption 2b]{\includegraphics{example-image}}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:second}
\end{minipage}

\bigskip
\begin{minipage}{0.48\linewidth}
\subfloat[caption 3a]{\includegraphics{example-image}}\hfill
\subfloat[caption 3b]{\includegraphics{example-image}}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:third}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
\subfloat[caption 4a]{\includegraphics{example-image}}\hfill
\subfloat[caption 4b]{\includegraphics{example-image}}

\caption{fffffffffffffffffffffffffffffffff}
\label{fig:fourth}
\end{minipage}
\end{figure*}
\end{document}