# Reference to List Items in Theorem Environment with Label Type “Theorem”

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}


-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Feb 28 at 11:26
add comment

## 2 Answers

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}


-
+1 for accepting the challenge and for the nice solution ;-) –  karlkoeller Feb 28 at 15:59
add comment

Here's a solution.

Define a new list lemlist

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


and use this one inside lem.

Then, declare

\Crefname{thmlisti}{Theorem}{Theorems}
\Crefname{lemlisti}{Lemma}{Lemmas}


and you will be able to avoid the optional argument for \labels.

MWE:

\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}
\newlist{lemlist}{enumerate}{1}
\setlist[lemlist]{label=(\roman{lemlisti}), ref=\thethm.(\roman{lemlisti}),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}
\Crefname{thmlisti}{Theorem}{Theorems}
\Crefname{lemlisti}{Lemma}{Lemmas}

\begin{document}

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

\begin{lem}\label{thm:B}
\begin{lemlist}
\item Statment 1\label{thm:B1}
\item Statment 2\label{thm:B2}
\end{lemlist}
\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}


Output:

-
That's only a partial solution, since you still end up hard-coding the theorem type somehow. –  T. Verron Feb 28 at 11:27
@T.Verron Not a big problem, I think. Do you have any better solution? –  karlkoeller Feb 28 at 12:47
Challenge accepted. :) Your approach could probably be mixed with theorem hooks too, and that may be a more robust solution for the whole problem. –  T. Verron Feb 28 at 13:33
add comment