ntheorem
宏包的 \thref
命令即提供此功能。查看文档第2.7节、3.2.1节、4.1节。
并且兼容已有的定理环境。
\documentclass[11pt]{ctexart}
\usepackage{amsmath}
\usepackage[amsmath,hyperref,thref]{ntheorem} % 注意 amsmath 和 hyperref 选项
\usepackage{hyperref}
\newtheorem{theorem}{定理}[section]
\renewcommand\thetheorem{\arabic{theorem}}
\newtheorem{corollary}{推论}[theorem]
\renewcommand\thecorollary{\arabic{corollary}}
\begin{document}
\section{test}
\begin{theorem}\label{th1}
S = ah
\end{theorem}
\begin{corollary}\label{co1}
abcd
\end{corollary}
% 不空白 和有空白
见\thref{th1} 和 \thref{co1}.
% 之所以出现的是“定理1.1”和“推论1.1.1”是因为ntheorem宏包暂不支持重定义 `\the<theorem>`。
\end{document}
但是由于 ntheorem
宏包不支持重定义 \the<theorem>
,此时可使用 cleveref
宏包的 \crefformat{}{}
命令修改:
% \usepackage{cleveref}
%\renewcommand\the....
\crefformat{theorem}{#2定理 #1#3}
\crefformat{corollary}{#2推论 #1#3}
完整的例子如下:注意此时 ntheorem
宏包是不需要的。
\documentclass[11pt]{ctexart}
\usepackage{amsmath}
% \usepackage[amsmath,thref,hyperref]{ntheorem}
\usepackage{hyperref}
\usepackage{cleveref}
\def\thref{\cref}
\newtheorem{theorem}{定理}[section]
\renewcommand\thetheorem{\arabic{theorem}}
\crefformat{theorem}{#2定理 #1#3}
\newtheorem{corollary}{推论}[theorem]
\renewcommand\thecorollary{\arabic{corollary}}
\crefformat{corollary}{#2推论 #1#3}
\begin{document}
\section{test}
\begin{theorem}\label{th1}
S = ah
\end{theorem}
\begin{corollary}\label{co1}
abcd
\end{corollary}
见\thref{th1} 和 \thref{co1}.
\hyperref[th1]{定理 1} 和 \hyperref[co1]{推论 1}
\end{document}
问 能不能在定义 label 时指定引用时显示的文字