# 'Referenced' subfigures gives arabic numerals in IEEE Trans.

I am using IEEE Trans template. I have inserted figures using subfig and everything looks fine. However, after looking closely into the text I see output like Fig VI-B, Fig V-Bb which appears very strange. Infact, I cant imagine 'Figure 19' is labelled Fig VI, what could the problem be and how do I address this.

A few questions are similar to mine but they are quite different also: This question mentions about figures appearing in roman numeral using a thesis template. In the answer subfigure was recommended but IEEE uses subfig class.

I include a MWE from this question. Whenever I like to reference

 \documentclass{IEEEtran}
\usepackage{lipsum}
\usepackage{graphicx}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false, font=normalsize, labelfont=sf, textfont=sf] {subfig}
\else
\usepackage[caption=false, font=footnotesize]{subfig}
\fi

\begin{document}

\section{A}
\lipsum

\section{B}
\lipsum[1-3]
\begin{figure}
\label{fig1}
\centering
\subfloat[a]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1a}\hfill
\subfloat[b]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1b}\\
\subfloat[c]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1c}\hfill
\subfloat[d]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1d}
\caption{Whatever}
\end{figure}
\lipsum[1-5]
\end{document}


## 2 Answers

In addition to fixing the two issues mentioned in your answer -- placing the \label instruction after the associated \caption statement, and making sure to use the correct arguments for \ref -- you also need make sure that the \label instruction associated with a given subfloat statements occurs inside the argument of \subfloat{...}.

E.g., instead of writing

\subfloat[a]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1a}


you should write

\subfloat[a]{%
\includegraphics[width=0.45\linewidth]{example-image}
\label{1a}}


A full MWE (minimum working example):

For sure, if \label{1a} occurred outside the scope of \subfloat, the output of the \cref instruction used would be

figure 1, figures 1b and 1c, and section I

Not good, right?

\documentclass{IEEEtran}
\usepackage{lipsum,graphicx}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false,
font=normalsize, labelfont=sf, textfont=sf]{subfig}
\else
\usepackage[caption=false, font=footnotesize]{subfig}
\fi
%% just for this example:
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}

\begin{document}

\section{AAA}
\lipsum[1-5]

\begin{figure}
%%\centering  % not needed
\subfloat[text]{%
\includegraphics[width=0.475\linewidth]{example-image}
\label{1a}}\hfill
\subfloat[text]{%
\includegraphics[width=0.475\linewidth]{example-image}
\label{1b}}

\subfloat[text]{%
\includegraphics[width=0.475\linewidth]{example-image}
\label{1c}}\hfill
\subfloat[text]{%
\includegraphics[width=0.475\linewidth]{example-image}
\label{1d}}

\caption{Whatever} \label{fig1}
\end{figure}

\bigskip
Some cross-references: \cref{fig1,1c,1b,1a}.
\end{document}

• Thanks @Mico for pointing that out. I think it was because I got the MWE from the link I provided. Actually in my code the labels were also in the brackets as show. If I had observed that I would have corrected it. Thanks once again. – Abdulhameed Apr 27 '18 at 2:03

When I was about to send this question, I observed a number of issues with my code which generated the problems.

1. As you can see from the MWE, the label for the figures was placed above i.e not below the subfloats. Bringing it below the caption of the figure solved the poor referencing for the figures.

2. For the subfigures, I observed they were also poorly referenced. It was based on the former template I used (a different journal template works well with this referencing). I had referenced them like \ref{1}a instead of \ref{1a}. Correcting these issues answered my question.

\documentclass{IEEEtran}
\usepackage{lipsum}
\usepackage{graphicx}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false, font=normalsize, labelfont=sf, textfont=sf] {subfig}
\else
\usepackage[caption=false, font=footnotesize]{subfig}
\fi

\begin{document}

\section{A}
\lipsum

\section{B}
\lipsum[1-3]
\begin{figure}
\centering
\subfloat[a]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1a}\hfill
\subfloat[b]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1b}\\
\subfloat[c]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1c}\hfill
\subfloat[d]{%
\includegraphics[width=0.45\linewidth]{example-image}}
\label{1d}
\caption{Whatever}
\label{fig1} % Put here not on top
\end{figure}
\lipsum[1-5]
\end{document}


Correct referencing for IEEE Tran: ...\ref{1a} not \ref{1}a

I decided to post this because, I had also previously searched for an answer on this website till I found out myself. Perhaps, others in a similar situation and myself can benefit from this in the future.

• Posting answers to one's own questions is ok in general. Posting both the query and the answer within the same minute, though, means that no one else has a meaningful chance to provide their own, separate comments and/or answers. – Mico Apr 27 '18 at 0:41
• Thanks for the comment @Mico, I was about sending the question when I found those issues and I thought I shouldn't delete the question. But, I could delete it if you feel that is more appropriate. – Abdulhameed Apr 27 '18 at 0:45
• No worries. Actually, I spotted a further issue in your answer, so I went ahead and posted a separate answer after all. – Mico Apr 27 '18 at 1:10