![如何获取小型大写的 \hyperref[…]{自定义表达式}?](https://linux22.com/image/444416/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E5%B0%8F%E5%9E%8B%E5%A4%A7%E5%86%99%E7%9A%84%20%5Chyperref%5B%E2%80%A6%5D%7B%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A1%A8%E8%BE%BE%E5%BC%8F%7D%EF%BC%9F.png)
考虑以下 MWE:
\documentclass[a4paper]{scrartcl}
\usepackage{amsthm}
\makeatletter
\newtheoremstyle{style3}{\topsep}{}{}{}{\scshape}{}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}.}
\theoremstyle{style3}
\newtheorem{axiom}{Axiom}[]
\makeatother
% REFERENCES SETTINGS
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=black]{hyperref}
\usepackage[capitalise,noabbrev,nameinlink]{cleveref}
\hypersetup{allcolors=blue}
\AtBeginDocument{
\let\namerefOld\nameref
\renewcommand{\nameref}[1]{\textsc{\namerefOld{#1}}}
}
\AtBeginDocument{
\let\crefOld\cref
\renewcommand{\cref}[1]{\textsc{\crefOld{#1}}}
}
\begin{document}
\begin{axiom}[Optimality]\label{opt}
Fancy definition.
\end{axiom}
I am currently writing that object y satisfies \nameref{opt}, but I would rather say that object y is \hyperref[opt]{optimal}. The problem is that the word \hyperref[opt]{optimal} should be in small caps but isn't.
\end{document}
从下面的输出中可以看出,问题在于该命令\hyperref[opt]{optimal}
没有以小写字母输出。我或许可以强制所有超链接都采用小写字母,但我还在参考资料部分提供了指向文章网页的超链接,我不希望这些超链接采用小写字母。
我当然可以\textsc{\hyperref[opt]{optimal}}
每次都写,但如果可能的话,我宁愿让它自动化。
感谢大家的时间。
答案1
测试此选项以查看是否有帮助:
\documentclass[a4paper]{scrartcl}
\usepackage{amsthm}
\makeatletter
\newtheoremstyle{style3}{\topsep}{}{}{}{\scshape}{}{ }{\thmname{#1} \thmnumber{#2} --- \thmnote{#3}.}
\theoremstyle{style3}
\newtheorem{axiom}{Axiom}[]
\makeatother
% REFERENCES SETTINGS
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=black]{hyperref}
\usepackage[capitalise,noabbrev,nameinlink]{cleveref}
\hypersetup{allcolors=blue}
\AtBeginDocument{
\let\namerefOld\nameref
\renewcommand{\nameref}[1]{{\let\dlower\lowercase\textsc{\namerefOld{#1}}}}
}
\AtBeginDocument{
\let\crefOld\cref
\renewcommand{\cref}[1]{\textsc{\crefOld{#1}}}
}
\newcommand\hyperrefSC[2][]{\hyperref[#1]{\textsc{#2}}}
\def\dlower#1{#1}
\begin{document}
\begin{axiom}[\dlower{O}ptimality]\label{opt}
Fancy definition.
\end{axiom}
I am currently writing that object y satisfies \nameref{opt}, but I would rather say that object y is \hyperrefSC[opt]{optimal}. The problem is that the word \hyperrefSC[opt]{optimal} should be in small caps but isn't.
\end{document}
\lowercase
对于你关于将首字母小写的最后一个请求,我将其放在一个虚拟命令中,该命令在定义中更改为非虚拟( )\nameref