0

I have a figure that contains four subfigures with captions and I want to cite the subfigure. I tried a lot but it didn't work out. Below is not working

\usepackage{subfigure}
Some text \subref{fig:multi-scale} Figure \ref{fig:overall_figure}

COMPLETE LATEX CODE

%%%% ijcai21.tex

\typeout{IJCAI--21 Instructions for Authors}

% These are the instructions for authors for IJCAI-21.

\documentclass{IEEEtran}

% Use the postscript times font! \usepackage{times} \usepackage{soul} \usepackage{url} %\usepackage[hidelinks] %\usepackage[utf8]{inputenc} %\usepackage[small]{caption} %\usepackage{graphicx} \usepackage{amsmath} \usepackage{amsthm} \usepackage{booktabs} \usepackage{algorithm} \usepackage{algorithmic} \urlstyle{same} \usepackage[table,xcdraw]{xcolor} \usepackage{comment} \usepackage{multirow} \usepackage{amsfonts} \usepackage{makecell} \usepackage[colorlinks=true,linkcolor=blue]{hyperref}%

%\usepackage{subfigure} %\usepackage{caption} %\usepackage{subfig} \usepackage{graphicx} \usepackage[caption=false]{subfig}

%\usepackage{cleveref}

% You need a newsubfloat element to use subcaption

\definecolor{mygray}{gray}{.92}

% thickline============================================================================== \makeatletter \def\thickhline{% \noalign{\ifnum0=}\fi\hrule \@height \thickarrayrulewidth \futurelet \reserved@a\@xthickhline} \def\@xthickhline{\ifx\reserved@a\thickhline \vskip\doublerulesep \vskip-\thickarrayrulewidth \fi \ifnum0={\fi}} \makeatother

\newlength{\thickarrayrulewidth} \setlength{\thickarrayrulewidth}{2\arrayrulewidth} %======================================================================================

\title{Deep Learning}

\author{ Anonymous Author \thanks{A. A is with the Department of Electrical and Computer Engineering, Georgia Institute of Technology, Atlanta, GA, 30332}% <-this % stops a space \thanks{Anonymous and Anonymous are with Anonymous University.}% <-this % stops a space \thanks{Manuscript Submission April 19, 2022; revised August 00, 0000.}}

\begin{document}

\maketitle

\begin{abstract} xxx \end{abstract}

% \begin{figure}[!t] \subfloat[Deep Residual Auto-Encoder]{\includegraphics[width=3cm]{cat.jpg}} \label{fig:deep_residual} \vspace{10pt} \subfloat[Multi-scale network]{\includegraphics[width=3cm]{cat.jpg}} \label{fig:multi-scale} \caption{Oversimplified view of single iterative networks for image compression} \label{fig:overall_figure} \end{figure}

Cross references: \subref{fig:deep_residual} and \subref{fig:multi-scale} of \ref{fig:overall_figure}

\small \bibliographystyle{IEEEtran} \bibliography{ijcai21}

\end{document}

Khawar Islam
  • 175
  • 1
  • 8

2 Answers2

2

The package subfigure has been obsolete and deprecated for several years. Its author provided the successor package subfig.

There is also a superior package called subcaption, but it is not compatible with IEEEtran:

Package caption Warning: Unknown document class (or package),
(caption)                standard defaults will be used.
See the caption package documentation for explanation.

The warning you get upon loading subcaption in a IEEEtran document means that captions will be overridden and this won't please the copy editor to whom you submit your article.

Solution: use subfig.

\documentclass{IEEEtran}

\usepackage{graphicx} \usepackage[caption=false]{subfig}

\usepackage{lipsum} % for mock text

\begin{document}

Cross references: \subref{fig:gdn_network} and \subref{fig:multi_layer} of \ref{fig:overall_figure}

\lipsum

\begin{figure}[!t] \centering

\subfloat[% GDN Network \cite{balle2016end}\label{fig:gdn_network}% ]{\includegraphics[width=3cm]{example-image}}

\subfloat[% Multi-layer GDN Network \cite{balle2017end}\label{fig:multi_layer}% ]{\includegraphics[width=3cm]{example-image}}

\caption{Global caption in the style IEEEtran defines\label{fig:overall_figure}} \end{figure}

\lipsum[2-12]

\end{document}

enter image description here

egreg
  • 1,121,712
0

Using the caption and subcaption packages you can define \label inside them.

The MWE follows:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subcaption}
\captionsetup{justification=centering}
\captionsetup[figure]{position=below}
\captionsetup[subfigure]{position=below}
\usepackage[colorlinks]{hyperref}
\begin{document}

\ref{fig:many_figures}, \autoref{fig:many_figures}. \ref{fig:gdn_network}, \autoref{fig:gdn_network}. \ref{fig:multi_layer}, \autoref{fig:multi_layer}.

\begin{figure}[!ht] \centering \caption{Many figures} \label{fig:many_figures} \subcaption{GDN Network\cite{balle2016end}}{\includegraphics[width=0.4\textwidth]{example-image}} \vspace{10pt} \label{fig:gdn_network} \subcaption{Multi-layer GDN Network \cite{balle2017end}}{\includegraphics[width=0.4\textwidth]{example-image-a}} \label{fig:multi_layer} \end{figure}

\ref{fig:fig_name}, \autoref{fig:fig_name}. \ref{subfig:fig_name-a}, \autoref{subfig:fig_name-a}. \ref{subfig:fig_name-b}, \autoref{subfig:fig_name-b}.

\begin{figure}[!ht] \centering \captionbox{Legend figure\label{fig:fig_name}}[\linewidth]{ \subcaptionbox{Legend a\label{subfig:fig_name-a}}{ \includegraphics[width=.2\linewidth]{example-image-a} }; \subcaptionbox{Legend b\label{subfig:fig_name-b}}{ \includegraphics[width=.2\linewidth]{example-image-b} } } \end{figure}

\begin{thebibliography}{1} \bibitem{balle2016end} Balle 2016 Reference text

\bibitem{balle2017end} Balle 2017 Reference text \end{thebibliography} \end{document}

enter image description here

FHZ
  • 3,939