[Tex/LaTex] Reference to List Items in Theorem Environment with Label Type “Theorem”

amsthmcross-referencingenumitemhyperreftheorems

I'm trying to set up references to list items in theorem environments. Using the thmtools and the cref-package I am able to reference theorem environments, such that the theorem type, e.g. theorem, lemma, corollary, is displayed in the reference (see Exam. 1).

Using the enumitem-package I refer to list items in theorem environments, such that the number of the theorem is displayed together with the item number in a reference (see Exam. 2).

Now to my question: Is there an elegant way to combine these two techniques, which would return the theorem type of the environment the list item is in as well as the combination of theorem and item number?
When I'm using the \autoref{•} command the label type item is displayed (see Exam. 3). Which makes sense since my list environment thmlist is derived form the enumerate environment. Using \cref{•} just produces two question marks (see Exam. 4).

At the moment I assign the type directly to the \label command as a optional parameter (see Exam. 5). But this solution requires me to hard code the theorem type plus TexMaker won't recognize the labels.

Since I like separating my theorems into parts an elegant solution for this problem would be very handy.

I shall be grateful for any hint or answer.

\documentclass[10pt,a4paper]{article}

% Input Type and AMS-Packages 
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}

% Typography
\usepackage{enumitem}

\newlist{thmlist}{enumerate}{1}
\setlist[thmlist]{label=(\roman{thmlisti}), ref=\thethm.(\roman{thmlisti}),noitemsep}

% Math, Operators and Theorems
\usepackage{thmtools}

\declaretheorem[
    name=Theorem,
    %refname={theorem,theorems},        %Lower Case Versions of Theorem Type
    Refname={Theorem,Theorems},
    numberwithin=section]{thm}
\declaretheorem[
    name=Lemma,
    %refname={lemma,lemmas},
    Refname={Lemma,Lemmas},
    sibling=thm]{lem}

% References
\usepackage{nameref,hyperref}
\usepackage[capitalize]{cleveref}

\Crefname{thm}{Theorem}{Theorems}
\Crefname{lem}{Lemma}{Lemmas}

\begin{document}

\begin{thm}\label{thm:A}
\begin{thmlist}
\item Statment 1\label{thm:A1}
\item Statment 2\label[thm]{thm:A2}
\end{thmlist}
\end{thm}

\begin{lem}\label{thm:B}
\begin{thmlist}
\item Statment 1\label{thm:B1}
\item Statment 2\label[lem]{thm:B2}
\end{thmlist}
\end{lem}

\begin{description}
\item[1:] That's how I refer to theorems and their like: \cref{thm:A} and \cref{thm:B}.
\item[2:] That's how I refer to parts of theorems but without the label type: \ref{thm:A1} and \ref{thm:B1}.
\item[3:] This happens when using \verb+\autoref{•}:+ \autoref{thm:A1} and \autoref{thm:B1}.
\item[4:] This happens when using \verb+\cref{•}:+ \cref{thm:A1} and \cref{thm:B1}.
\item[5:] My current work around: \cref{thm:A2} and \cref{thm:B2}.
\end{description}
\end{document}

Result

Best Answer

This is an attempt based on your example. I used the theorem hooks defined by thmtools to override the format for thmlisti in the current environment:

\addtotheorempostheadhook[thm]{\crefalias{thmlisti}{thm}}
\addtotheorempostheadhook[lem]{\crefalias{thmlisti}{lem}}

I cannot promise that it won't break anything, for example if you use a thmlist without any surrounding theorem.

\documentclass[10pt,a4paper]{article}

% Input Type and AMS-Packages 
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}

% Typography
\usepackage{enumitem}

\usepackage{letltxmacro}

\newlist{thmlist}{enumerate}{1}
\setlist[thmlist]{label=(\roman{thmlisti}), ref=\thethm.(\roman{thmlisti}),noitemsep}


% Math, Operators and Theorems
\usepackage{thmtools}

\declaretheorem[
name=Theorem,
%refname={theorem,theorems},        %Lower Case Versions of Theorem Type
Refname={Theorem,Theorems},
numberwithin=section]{thm}
\declaretheorem[
name=Lemma,
%refname={lemma,lemmas},
Refname={Lemma,Lemmas},
sibling=thm]{lem}

% References
\usepackage{nameref,hyperref}
\usepackage[capitalize]{cleveref}

\Crefname{thm}{Theorem}{Theorems}
\Crefname{lem}{Lemma}{Lemmas}

%%% NEW
\addtotheorempostheadhook[thm]{\crefalias{thmlisti}{thm}}
\addtotheorempostheadhook[lem]{\crefalias{thmlisti}{lem}}

\begin{document}

\begin{thm}\label{thm:A}
  \begin{thmlist}
    \item Statment 1\label{thm:A1}
    \item Statment 2\label[thm]{thm:A2}
  \end{thmlist}
\end{thm}

\begin{lem}\label{thm:B}
  \begin{thmlist}
    \item Statment 1\label{thm:B1}
    \item Statment 2\label[lem]{thm:B2}
  \end{thmlist}
\end{lem}

\begin{description}
  \item[1:] That's how I refer to theorems and their like: \cref{thm:A} and \cref{thm:B}.
  \item[2:] That's how I refer to parts of theorems but without the label type: \ref{thm:A1} and \ref{thm:B1}.
  \item[3:] This happens when using \verb+\autoref{•}:+ \autoref{thm:A1} and \autoref{thm:B1}.
  \item[4:] This happens when using \verb+\cref{•}:+ \cref{thm:A1} and \cref{thm:B1} (now working)
  \item[5:] My current work around: \cref{thm:A2} and \cref{thm:B2}.
\end{description}
\end{document}

Result