You can locally override the label type with \label[<type>]{<key>}
, so at the start of each theorem you can define \thmtype
to be the environment name and define \plabel{<key>}
as \label[\thmtype]{<key>}
. I first tried to overwrite the definition of \label
so you wouldn't have to use a different command, but for reasons I don't understand something like \NewCommandCopy{\origlabel}{\label}
doesn't copy the definition of \label
in the way I'd expect.
\documentclass{book}\usepackage{amsthm}\usepackage[shortlabels]{enumitem}\usepackage[colorlinks]{hyperref}\usepackage[capitalize,nameinlink]{cleveref}\newtheorem{theorem}{Theorem}[chapter]\newtheorem{lemma}[theorem]{Lemma}\theoremstyle{definition}\newtheorem{defin}[theorem]{Definition}\crefname{defin}{Definition}{Definitions} % needed since cleveref only predefines for fixed set of theorem names\newlist{thmparts}{enumerate}{1}\setlist[thmparts]{ label=(\roman*), ref=\thetheorem\,(\roman*), }\newcommand{\plabel}[1]{\label[\thmtype]{#1}}\makeatletter\apptocmd{\@begintheorem}{\let\thmtype\@currenvir}{}{\ERROR}\makeatother\begin{document}\begin{defin}\label{defin_1}\leavevmode \begin{thmparts} \item\plabel{item_1} Part 1 \dots \item\plabel{item_2} Part 2 \dots \end{thmparts} \thmtype\end{defin}\begin{theorem}\label{thm_1}\leavevmode \begin{thmparts} \item\plabel{thmitem_1} Part 1 \dots \item\plabel{thmitem_2} Part 2 \dots \end{thmparts} \thmtype\end{theorem}\begin{lemma}\label{lem_1}\leavevmode \begin{thmparts} \item\plabel{lemitem_1} Part 1 \dots \item\plabel{lemitem_2} Part 2 \dots \end{thmparts} \thmtype\end{lemma}\cref{defin_1} consists of the \cref{item_1,item_2}.\cref{thm_1} consists of the \cref{thmitem_1,thmitem_2}.\cref{lem_1} consists of the \cref{lemitem_1,lemitem_2}.\end{document}