为什么 autoref 对声明不起作用?

为什么 autoref 对声明不起作用?

因此,我尝试使用 autoref 引用声明

  \documentclass[a4paper,UKenglish]{article}
\usepackage{graphicx}
% Used for displaying a sample figure. If possible, figure files should
% be included in EPS format.
%
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}
\newtheorem{theorem}{theorem}
\newtheorem{claim}{Claim}
\usepackage{comment}

\newcommand{\claimautoref}{claim}

 \usepackage{caption}
 \usepackage{subcaption}

 \renewcommand{\thesubfigure}{\roman{subfigure}}

 \usepackage[ruled,vlined,algo2e]{algorithm2e}
 \usepackage[utf8]{inputenc}
\usepackage{xcolor}
 \usepackage{hyperref}


\begin{document}

\begin{claim}\label{add}
adfsafda
\end{claim}
\autoref{add}       

\end{document}

答案1

所需宏的正确名称是\claimautorefname,而不是\claimautoref

在此处输入图片描述

\documentclass[a4paper,UKenglish]{article}
\usepackage{amsthm}
\newtheorem{claim}{Claim}

\usepackage[colorlinks,allcolors=blue]{hyperref}
\newcommand{\claimautorefname}{claim} % <-- note name of macro

\begin{document}
\begin{claim}\label{add} adfsafda\end{claim}
\noindent
According to \autoref{add}, \dots
\end{document}

相关内容