我希望cleveref
打印的每个名称都以小写字母书写。目前,我使用\crefname
和手动为每个我能想到的名称执行此\Crefname
操作,但这不是一个优雅的解决方案,而且是一个糟糕的解决方案,因为:
- 对于我想要的
\crefname
每个环境都添加是非常耗时的;\newtheorem
- 我可能会忘记 cleveref 使用的一些名称,只有在文档完成后才发现。
我已阅读此帖子格式化 cleveref 标签(包括名称)但是提供的解决方案不能解决我的需求,因为我还希望,当我引用多个对象(使用\cref
、\crefrange
之类的)时,连词“and”的文本不是小写,只有 创建的链接hyperref
。
hyperref
有没有办法在创建链接时使用小写字母显示文字?
平均能量损失
\documentclass[oneside]{article}
\usepackage{amsthm}
\usepackage[hidelinks,linktocpage]{hyperref}
\usepackage[nameinlink]{cleveref}
\crefname{figure}{\textsc{figure}}{\textsc{figures}}
\Crefname{figure}{\textsc{Figure}}{\textsc{Figures}}
\crefname{table}{\textsc{table}}{\textsc{tables}}
\Crefname{table}{\textsc{Table}}{\textsc{Tables}}
\crefname{theorem}{\textsc{theorem}}{\textsc{theorems}}
\Crefname{theorem}{\textsc{Theorem}}{\textsc{Theorems}}
\crefname{definition}{\textsc{definition}}{\textsc{definitions}}
\Crefname{definition}{\textsc{Definition}}{\textsc{Definitions}}
\crefname{equation}{\textsc{equation}}{\textsc{equations}}
\Crefname{equation}{\textsc{Equation}}{\textsc{Equations}}
\newtheorem{theorem}{Theorem}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\begin{document}
\section{Section}
\label{section}
\section{Subsection}
\label{subsection}
\section{Subsubsection}
\label{subsubsection}
\begin{definition}
\label{definition}
A definition.
\end{definition}
\begin{theorem}
\label{theorem}
A theorem.
\end{theorem}
\begin{equation}
\label{equation}
0=1
\end{equation}
\begin{figure}
%\includegraphics{example-image-a}}
\caption{An image.}
\label{figure}
\end{figure}
\begin{table}
\centering
\begin{tabular}{c|c}
0 & 1 \\
2 & 3
\end{tabular}
\caption{A table.}
\label{table}
\end{table}
References to \cref{section}, \cref{subsection} and \cref{subsubsection}. References to \cref{definition}, \cref{theorem}, \cref{equation}, \cref{figure} and \cref{table}.
\end{document}
答案1
您可以修补\@cref
:
\documentclass[oneside]{article}
\usepackage{amsthm}
\usepackage[linktocpage,hidelinks]{hyperref}
\usepackage[nameinlink]{cleveref-usedon}
\makeatletter
\patchcmd{\@cref}{\begingroup}{\begingroup\scshape}{}{}
\AfterBeginDocument{
\renewcommand{\crefrangeconjunction}{ \textnormal{to}\nobreakspace}%
\renewcommand{\crefpairconjunction}{ \textnormal{and}\nobreakspace}%
\renewcommand{\creflastconjunction}{ \textnormal{and}\nobreakspace}%
\renewcommand{\crefpairgroupconjunction}{ \textnormal{and}\nobreakspace}%
\renewcommand{\creflastgroupconjunction}{, \textnormal{and}\nobreakspace}%
}
\makeatother
\newtheorem{theorem}{Theorem}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\begin{document}
\section{Section}
\label{section}
\section{Subsection}
\label{subsection}
\section{Subsubsection}
\label{subsubsection}
\begin{definition}
\label{definition}
A definition.
\end{definition}
\begin{theorem}
\label{theorem}
A theorem.
\end{theorem}
\begin{equation}
\label{equation}
0=1
\end{equation}
\begin{figure}
%\includegraphics{example-image-a}}
\caption{An image.}
\label{figure}
\end{figure}
\begin{table}
\centering
\begin{tabular}{c|c}
0 & 1 \\
2 & 3
\end{tabular}
\caption{A table.}
\label{table}
\end{table}
References to \cref{section,subsection} and \cref{subsubsection}. References to \cref{definition}, \cref{theorem}, \cref{equation}, \cref{figure} and \cref{table}.
\end{document}
答案2
如果你使用PDF管理(通过加载)\DocumentMetadata
在链接前有一个钩子可以设置:
\DocumentMetadata{}
\documentclass[oneside]{article}
\usepackage{amsthm}
\usepackage[hidelinks,linktocpage]{hyperref}
\usepackage[nameinlink]{cleveref}
\makeatletter
\ActivateGenericHook{hyp/link/cref}
\AddToHook{hyp/link/cref}{\scshape}
\ExplSyntaxOn
\def\cref@hyperlink#1#2#3\@nil{\hyper@link{cref}{#2}{#3}}
\ExplSyntaxOff
\makeatother
\newtheorem{theorem}{Theorem}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\begin{document}
\section{Section}
\label{section}
\section{Subsection}
\label{subsection}
\section{Subsubsection}
\label{subsubsection}
\begin{definition}
\label{definition}
A definition.
\end{definition}
\begin{theorem}
\label{theorem}
A theorem.
\end{theorem}
\begin{equation}
\label{equation}
0=1
\end{equation}
\begin{figure}
%\includegraphics{example-image-a}}
\caption{An image.}
\label{figure}
\end{figure}
\begin{table}
\centering
\begin{tabular}{c|c}
0 & 1 \\
2 & 3
\end{tabular}
\caption{A table.}
\label{table}
\end{table}
References to \cref{section}, \cref{subsection} and \cref{subsubsection}. References to \cref{definition}, \cref{theorem}, \cref{equation}, \cref{figure} and \cref{table}.
\crefrange{section}{subsection}
\end{document}