在定理环境中引用枚举中的硬编码项

在定理环境中引用枚举中的硬编码项

我试图在定理环境中引用枚举中的硬编码项。(c1)我没有得到定理的标签,而是得到了定理的标签。有快速解决方法吗?

\documentclass[11pt]{article}
\usepackage{amsmath, cleveref}

\newtheorem{theorem}{Theorem}

\begin{document}
    \begin{theorem}
        Properties
        \begin{enumerate}
            \item[(c1)] a \label{c1}
            \item[(c2)] b
            \item[(k)]  c
            \item[(n1)] d
            \item[(n2)] e
        \end{enumerate}
    \end{theorem}
    \ref{c1}, \cref{c1}
\end{document}

在此处输入图片描述

答案1

你可以arblabel如何正确实现cleveref\cref@currentlabel定义交叉引用为您的定理列表创建“自定义定理类参考”:

在此处输入图片描述

\documentclass{article}

\usepackage{hyperref}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}

%\usepackage{xparse}

\makeatletter

\NewDocumentCommand{\arblabel}{O{theoremext}m+m}{%
  \begingroup
  \cref@constructprefix{#1}{\cref@result}%
  \protected@edef\@currentlabel{%
    #3}%
  \protected@edef\@currentlabelname{#3}%
  \protected@edef\cref@currentlabel{%
    [#1][][\cref@result]%
    #3%
  }
  \label[#1]{#2}%
  \endgroup  
}

\makeatother

\crefname{theoremext}{theorem}{theorems}% Name of theorem extensions
\Crefname{theoremext}{Theorem}{Theorems}% Name of Theorem extensions

\begin{document}

\begin{theorem}
  Properties
  \begin{itemize}
    \item[(c1)] a \arblabel{c1}{(c1)}% Theorem (c1) (label is c1)
    \item[(c2)] b
    \item[(k)]  c
    \item[(n1)] d
    \item[(n2)] e
  \end{itemize}
\end{theorem}

\cref{c1}, \Cref{c1}

\end{document}

相关内容