![如果定理类环境的计数器共享,则会出现交叉引用问题](https://linux22.com/image/410528/%E5%A6%82%E6%9E%9C%E5%AE%9A%E7%90%86%E7%B1%BB%E7%8E%AF%E5%A2%83%E7%9A%84%E8%AE%A1%E6%95%B0%E5%99%A8%E5%85%B1%E4%BA%AB%EF%BC%8C%E5%88%99%E4%BC%9A%E5%87%BA%E7%8E%B0%E4%BA%A4%E5%8F%89%E5%BC%95%E7%94%A8%E9%97%AE%E9%A2%98.png)
问题是当我共享编号时\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}