我有一张包含四个子图的图,并附有标题,我想引用子图。我尝试了很多方法,但都没有成功。下面不起作用
\usepackage{subfigure}
Some text \subref{fig:multi-scale} Figure \ref{fig:overall_figure}
完整的 Latex 代码
%%%% 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}
答案1
此软件包subfigure
已过时且弃用多年。其作者提供了后续软件包subfig
。
还有一个名为的高级包subcaption
,但它是不是兼容IEEEtran
:
Package caption Warning: Unknown document class (or package),
(caption) standard defaults will be used.
See the caption package documentation for explanation.
subcaption
加载文档时收到的警告IEEEtran
意味着标题将被覆盖,而这不会让您提交文章的编辑感到高兴。
解决方案:使用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}
答案2
使用caption
和subcaption
包,您可以\label
在其中定义。
MWE 如下:
\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}