文档amsart
类自动使用小型大写字母作为子图标签,即 (A)、(B)、(C) 使用小型大写字母,而不是 (a)、(b)、(c)。但是,cleverref
在使用时仍会将它们称为图 1a、图 1b、图 1c \cref
。我该如何修改\cref
以使用小型大写字母?
答案1
像这样吗?
\documentclass{amsart}
\usepackage{subcaption}
\usepackage{cleveref}
\crefdefaultlabelformat{#2{\scshape #1}#3}
\crefname{subfigure}{fig.}{figs.}
\Crefname{subfigure}{Fig.}{Figs.}
\begin{document}
\section{Foo}
\begin{figure}
\begin{subfigure}{0.5\textwidth}
\caption{Foo label}
\label{Foo}
\end{subfigure}
\end{figure}
\Cref{Foo} and \cref{Foo}
\end{document}
更新
使用循环定义\crefformat
提供给宏的计数器列表\addcountertoseq
:
\documentclass{amsart}
\usepackage{xparse}
\usepackage{subcaption}
\usepackage{hyperref}
\usepackage{cleveref}
\ExplSyntaxOn
\makeatletter
\seq_new:N \l_jcb_counter_seq
\newcommand{\addcountertoseq}[1]{%
\seq_set_from_clist:Nn \l_jcb_counter_seq {#1}
}
\newcommand{\switchtosmallcapsformat}{%
\seq_map_inline:Nn \l_jcb_counter_seq {%
\crefformat{##1}{####2{\protect\scshape\use:c{cref@##1@name}\ ####1}####3}
\Crefformat{##1}{####2{\protect\scshape\use:c{Cref@##1@name}\ ####1}####3}
}%
}
\ExplSyntaxOff
\makeatother
\addcountertoseq{section,subsection,subsubsection,part,figure,table,page,equation}
\switchtosmallcapsformat
\begin{document}
Outlook: In \cref{foo} we will see that ... and \cref{foofigure} shows that
Outlook: In \Cref{foo} we will see that ... and \Cref{foofigure} shows that
\clearpage
\section{Foo}\label{foo}
\begin{figure}
\begin{subfigure}{0.5\textwidth}
\caption{Foo label}
\label{foofigure}
\end{subfigure}
\end{figure}
\end{document}