问题是当我共享编号时\cref
无法显示名称,即使\crefname
显示\autoref
所有名称也是如此Equation
。
以下是 MWE:
%&latex
\documentclass{amsart}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% If you want to insert other packages. Insert them here
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\numberwithin{equation}{section}
\newtheorem{The}[equation]{Theorem}
\crefname{The}{Theorem}{Theorems}
\newtheorem{Dfn}[equation]{Definition}
\newtheorem{Lem}[equation]{Lemma}
\newtheorem{Prs}[equation]{Proposition}
\newtheorem{Crl}[equation]{Corollary}
\newtheorem{Rmk}[equation]{Remark}
\begin{The}\label{T1}
Assume ...
\end{The}
...
\begin{Dfn}\label{D1}
Assume ...
\end{Dfn}
...
\begin{Lem}\label{L1}
Assume ...
\end{Lem}
...
\begin{Prs}\label{P1}
Assume ...
\end{Prs}
...
\begin{Crl}\label{C1}
Assume ...
\end{Crl}
...
\begin{Rmk}\label{R1}
Assume ...
\end{Rmk}
\begin{equation}\label{E1}
Assume ... \bigskip
\end{equation}
\noindent
\cref{T1} \\
\cref{D1} \\
\cref{L1} \\
\cref{P1} \\
\cref{C1} \\
\cref{R1} \\
\cref{E1} \\
\noindent
\autoref{T1} \\
\autoref{D1} \\
\autoref{L1} \\
\autoref{P1} \\
\autoref{C1} \\
\autoref{R1} \\
\autoref{E1} \\
\end{document}
我该如何解决?
答案1
如果要cleveref
正确选择类定理环境的名称,则\newtheorem
必须出现声明前,而不是在\begin{document}
声明之后。这就是@leandriis试图在评论中告诉你。
\documentclass{amsart}
%\usepackage{amsthm} % is loaded automatically by 'amsart' class
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}
\numberwithin{equation}{section}
\newtheorem{The}[equation]{Theorem}
\newtheorem{Dfn}[equation]{Definition}
\newtheorem{Lem}[equation]{Lemma}
\newtheorem{Prs}[equation]{Proposition}
\newtheorem{Crl}[equation]{Corollary}
\newtheorem{Rmk}[equation]{Remark}
\begin{document}
\setcounter{section}{2} % just for this example
\begin{The}\label{T1} Assume \dots \end{The}
\begin{Dfn}\label{D1} Assume \dots \end{Dfn}
\begin{Lem}\label{L1} Assume \dots \end{Lem}
\begin{Prs}\label{P1} Assume \dots \end{Prs}
\begin{Crl}\label{C1} Assume \dots \end{Crl}
\begin{Rmk}\label{R1} Assume \dots \end{Rmk}
\begin{equation}\label{E1} 1+1=2 \end{equation}
\bigskip\noindent
\cref{T1,D1,L1,P1,C1,R1,E1}
\end{document}