我已经将图中的子图格式化如下
\usepackage{subfigure}
\begin{figure}
\centering
\subfigure[]{\label{fig:sub:a} \includegraphics{...}}
\subfigure[]{\label{fig:sub:b} \includegraphics{...}}
\subfigure[]{\label{fig:sub:c} \includegraphics{...}}
\caption {Three subfigures. (\textit{a})xxx, (\textit{b})xxx, and (\textit{c})xxx.}
\label{multifigures}
\end{figure}
现在我想引用multifigures
如图 (\textit{a}-\textit{c}),如图 1 (A-C)。也就是说,我希望字母是斜体,并且只用一个括号括起来,数字编号在括号外。我试了一下\ref{fig:sub:a}--\subref{fig:sub:c}
,但它给了我图 (a)-(c),字体是直立的,每个字母周围都有单独的括号。
答案1
您可以通过结合使用cleveref
和来实现这一点subcaption
:
\documentclass{scrartcl}
\usepackage[]{graphicx}
\usepackage{subcaption}
% label is a, b ...
\renewcommand\thesubfigure{\alph{subfigure}}
\usepackage[unicode]{hyperref}
% multiple refs are compressed to a range with the compress option
\usepackage[compress]{cleveref}
% define the subfigure ref class
\crefname{subfigure}{subfigure}{subfigures}
\Crefname{subfigure}{Subfigure}{Subfigures}
% this is the formatting command for the subfigure ranges:
% the important part is the \crefstripprefix which removes the
% figure number from the second label. #1 is the first label, #2 the second.
% the rest are start and end markers for the hyperlinks.
\crefrangelabelformat{subfigure}{(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}
\begin{document}
\begin{figure}
\caption{All}
\begin{subfigure}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{test}
\label{subfig:1}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{test}
\label{subfig:2}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{test}
\label{subfig:3}
\end{subfigure}
\label{fig:1}
\end{figure}
See \cref{subfig:1,subfig:2,subfig:3}
\end{document}
这不适用于斜体,我不知道为什么。但是如果你重新定义
\renewcommand\thesubfigure{\itshape\alph{subfigure}}
命令 \crefstripprefix 会引发错误。
结果: