使用 Cleveref 将子图标签以斜体和括号放置在正常字体中

使用 Cleveref 将子图标签以斜体和括号放置在正常字体中

我正在写一篇文章,根据格式规范,我需要将子图标签用斜体表示,并将其括号用普通罗马字体表示(不带斜体),即(A) 作为标签。同样,我需要以相同的方式交叉引用子图,即斜体字母数字标签和正常字体括号,例如图 1(A)。请指教如何使用 cleveref 和 subfig 包实现这一点,如下方 MWE 所示。

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[capitalise]{cleveref}

\graphicspath{{figures/}}


\usepackage[labelformat=simple,labelfont=it]{subfig}%places subfig labels in italic
\renewcommand{\thesubfigure}{(\alph{subfigure})}%alphabetic subfigure numbering
\crefrangelabelformat{figure}{#3#1#4--(#5\crefstripprefix{#1}{#2}#6} 
    %add dash as between subfig numbers and Strips redundant 
    %figure digit to be Figures 11(a)-(g)

    \begin{document}
    My challenge is place the subfigure labels in italics and their 
    parentheses in normal roman font (without italics).

\begin{figure}
\centering
\captionsetup{justification=raggedright}
\subfloat[text]{\label{fig:1a}\includegraphics{file1.eps}}\qquad
\subfloat[text]{\label{fig:1b}\includegraphics{file2.eps}}\\
\subfloat[text]{\label{fig:1c}\includegraphics{file3.eps}}\qquad
\subfloat[text]{\label{fig:1d}\includegraphics{file4.eps}}
\caption{Now these labels \protect\subref*{fig:1a}, 
    \protect\subref*{fig:1b}, $\dots$, \protect\subref*{fig:1d} should be 
    placed in italics and their parenthesis in normal roman font (without 
    italics), i.e (\textit{a})}
\label{fig:1}
\end{figure}

    Moreover, I wish to crossreference this \Cref{fig:1a} with the label "a" 
    in italics and parenthesis in normal roman font (without italics), i.e., 
    Figure~(\textit{a}) and similarly \Cref{fig:1a,fig:1b,fig:1c,fig:1d}, 
    i.e. Figures~(\textit{a})--(\textit{d}) .

\end{document}  

答案1

如果我正确理解了您的格式目标,您不希望在子图的交叉引用中包含图号。如果这种解释正确,则以下解决方案应该适合您。

在此处输入图片描述

\documentclass{article}
\usepackage[demo]{graphicx}
\graphicspath{{figures/}}
\usepackage[labelformat=simple]{subfig}
\usepackage[capitalise,noabbrev]{cleveref}

\makeatletter
\renewcommand{\p@subfigure}{} % remove the figure number "prefix"
\makeatother
%% only the alphabetic label should be in italics:
\renewcommand{\thesubfigure}{(\textit{\alph{subfigure}})}
%% change range conjunction indicator to "en-dash" (default is " to ")
\newcommand\crefrangeconjunction{--}

\begin{document}

\begin{figure}

\subfloat[text]{\label{fig:1a}\includegraphics{file1.eps}}\hspace{\fill}
\subfloat[text]{\label{fig:1b}\includegraphics{file2.eps}}

\subfloat[text]{\label{fig:1c}\includegraphics{file3.eps}}\hspace{\fill}
\subfloat[text]{\label{fig:1d}\includegraphics{file4.eps}}

\caption{The labels \protect\subref*{fig:1a}, \protect\subref*{fig:1b}, 
   \dots, \protect\subref*{fig:1d} should be placed in italics and 
   their parentheses in normal roman font (without italics), i.e., 
   (\textit{a}), etc.}
\label{fig:1}
\end{figure}

My challenge is to place the subfigure labels in italics and their 
parentheses in upright roman font (without italics).

E.g., I wish to cross-reference \Cref{fig:1a} with the label~``a'' in 
italics and the parentheses in normal roman font (without italics), i.e., 
``Figure~(\textit{a})''.

Finally, both \cref{fig:1a,fig:1b,fig:1c,fig:1d} and 
\crefrange{fig:1a}{fig:1d} should be typeset as 
``Figures~(\textit{a})--(\textit{d})''.

\end{document} 

相关内容