我用它来\autoref
在我的文档中引用图表。
这是一个带有代码的示例。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}
\usepackage{float}
\usepackage[hidelinks]{hyperref}
\renewcommand\thefigure{\thesection-\arabic{figure}} % the counter style
\captionsetup[figure]{labelfont={bf},name={Fig},labelsep=space} % other settings
\begin{document}
\section{Title of Section}
\par Fig \autoref{subfigure1} is the first subfigure, Fig \autoref{subfigure2} is the second subfigure, and they are in \autoref{figures}
\begin{figure}[H]
\centering
\subfloat[Subfigure 1]{\includegraphics[width=.4\linewidth]{example-image-a}\label{subfigure1}}
\subfloat[Subfigure 2]{\includegraphics[width=.4\linewidth]{example-image-b}\label{subfigure2}}
\caption{Figure} \label{figures}
\end{figure}
\end{document}
该文件如下图所示。
可以看出,子图被引用为图 1-1a 和图 1-1b。那么有没有方法可以像标题中那样引用它们,如图 1-1(a) 和图 1-2(b)?
答案1
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}
\usepackage{float}
\usepackage[hidelinks]{hyperref}
\renewcommand\thefigure{\thesection-\arabic{figure}} % the counter style
\captionsetup[figure]{labelfont={bf},name={Fig},labelsep=space} % other settings
\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfigure]{labelformat=simple}
\begin{document}
\section{Title of Section}
\par Fig \autoref{subfigure1} is the first subfigure, Fig \autoref{subfigure2} is the second subfigure, and they are in \autoref{figures}
\begin{figure}[H]
\centering
\subfloat[Subfigure 1]{\includegraphics[width=.4\linewidth]{example-image-a}\label{subfigure1}}
\subfloat[Subfigure 2]{\includegraphics[width=.4\linewidth]{example-image-b}\label{subfigure2}}
\caption{Figure} \label{figures}
\end{figure}
\end{document}