在所有环境中放置相同的计数器后进行自动引用

在所有环境中放置相同的计数器后进行自动引用

我有一个 xelatex amsart 文档,其中我首先定义了一个计数器

\newcounter{thms}

然后定义环境,

\theoremstyle{definition}
\newtheorem{thms}{Theorem}
\newtheorem{defni}[thms]{Definition}
\newtheorem{lem}[thms]{Lemma}

不过,我还想更改其自动引用的名称

\newcommand{\lemautorefname}{Lemma}
\newcommand{\thmautorefname}{theorem}

但当我尝试自动引用时,我发现引理和定理都被命名为“定理 1.X”。您知道如何解决这个问题吗,以便引理以其名称命名,定理以其自动引用的名称命名?

编辑:梅威瑟:

\documentclass[12pt,reqno,,usenames,dvipsnames]{amsart}
\usepackage[utf8]{inputenc}    
\usepackage{amssymb}
\usepackage[shortlabels]{enumitem}
\usepackage{hyperref}
\usepackage{mathrsfs}
\usepackage{setspace}

\allowdisplaybreaks
\date{\today}
\theoremstyle{remark}

\newcounter{thms}
\usepackage[toc,page]{appendix}
\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newtheorem{lem}[thm]{Lemma}
\newcommand{\lemautorefname}{lemma}
\newcommand{\thmautorefname}{theorem}
\begin{document}
\section{First section}
\begin{thm}\label{stupid}
My first theorem is stupid
\end{thm}
\begin{lem}\label{stupid2}
Also silly
\end{lem}
Both \autoref{stupid} and \autoref{stupid2} are silly. 
\end{document}

答案1

你可以这样做aliascnt

\documentclass[12pt,reqno]{amsart}
\usepackage{amssymb}
\usepackage[shortlabels]{enumitem}
\usepackage{mathrsfs}
\usepackage{setspace}
\usepackage[toc,page]{appendix}
\usepackage{aliascnt}

\usepackage{hyperref}

\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newaliascnt{lem}{thm}
\newtheorem{lem}[lem]{Lemma}
\aliascntresetthe{lem}

\newcommand{\lemautorefname}{lemma}
\newcommand{\thmautorefname}{theorem}

\begin{document}

\section{First section}

\begin{thm}\label{stupid}
My first theorem is stupid
\end{thm}

\begin{lem}\label{stupid2}
Also silly
\end{lem}

Both \autoref{stupid} and \autoref{stupid2} are silly. 

\end{document}

在此处输入图片描述

或者,使用cleveref

\documentclass[12pt,reqno]{amsart}
%\usepackage[utf8]{inputenc} % <---- don't use this with XeLaTeX
\usepackage{amssymb}
\usepackage[shortlabels]{enumitem}
\usepackage{mathrsfs}
\usepackage{setspace}
\usepackage[toc,page]{appendix}

\usepackage{hyperref}
\usepackage{cleveref}

\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newtheorem{lem}[thm]{Lemma}

\allowdisplaybreaks

\begin{document}

\section{First section}

\begin{thm}\label{stupid}
My first theorem is stupid
\end{thm}

\begin{lem}\label{stupid2}
Also silly
\end{lem}

Both \cref{stupid} and \cref{stupid2} are silly. 

\end{document}

在此处输入图片描述

相关内容