Referencing an in-theorem list item without the preceding theorem number

I am trying to define a variant of \ref that picks out only the item number of an in-theorem list item without the preceding theorem number. For example:

Theorem 1.1.

(i) Something important.

(ii) Something important that refers to (i).

However, I can only manage the following:

Theorem 1.1.

(i) Something important.

(ii) Something important that refers to 1.1(i).

Note that I do still want to be able to print the counter 1.1(i), since I may wish to use it later on in the document. That is, in addition to being able to print 1.1(i) and Theorem 1.1(i) using the commands \ref{theoremlabel} and \Cref{theoremlabel} respectively, I'd like a new command \itemref{itemlabel} that prints just (i). I would like all three to be clickable too (using the hyperref package).

Note that this is very similar to the question ref to subsection number only and I've tried to adapt the solution givien there by Marco Daniel but alas my TeX coding skills are lacking.

Here's my MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

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

\usepackage{hyperref}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\Crefname{thm}{Theorem}{Theorems}

\begin{document}

\section{A theorem}

\begin{thm}\label{theoremlabel}~
\begin{thmlist}

\item\label{itemlabel} Something important.

\item Something important about \ref{itemlabel}. [Here's where I'd like to use my proposed \verb+\itemref{itemlabel}+ command.]

\end{thmlist}
\end{thm}

Later on in my document... Isn't \Cref{theoremlabel} interesting? I particularly like its clickable counter \ref{theoremlabel}.

\end{document}


Notet: The clever trick using the \addtotheorempostheadhook command is due to T. Verron in the question Reference to List Items in Theorem Environment with Label Type “Theorem”.

• I've an idea with refcount in my mind, in conjunction with xstring. – user31729 Sep 9 '15 at 16:38
• – John Kormylo Sep 9 '15 at 17:01

You can use the \p@<counter> feature: when the counter's representation, it's preceded by the expansion of \p@<counter> (usually empty), which we can use for our purposes, that is inserting in it \thethm, but as the argument to another command that we can redefine at point of use.

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{enumitem}
\newlist{thmlist}{enumerate}{1}
\setlist[thmlist]{label=(\roman{thmlisti})}
\makeatletter
\renewcommand{\p@thmlisti}{\perh@ps{\thethm}}
% the same \DeclareRobustCommand{\perh@ps}[1]{#1}, but more efficient
\protected\def\perh@ps#1{#1}

\newcommand{\itemref}[1]{%
\begingroup % locally disable \perh@ps
\let\perh@ps\@gobble\ref{#1}%
\endgroup
}
\makeatother

\usepackage{hyperref}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\Crefname{thm}{Theorem}{Theorems}

\begin{document}

\section{A theorem}

\begin{thm}\label{theoremlabel}\mbox{}
\begin{thmlist}

\item\label{itemlabel} Something important.

\end{thmlist}
\end{thm}

Later on in my document... Isn't \Cref{theoremlabel} interesting?
I particularly like its clickable counter \ref{theoremlabel}
and \ref{itemlabel}.

\end{document}


Alternative solution, that satisfies Barbara Beeton's and my tastes, with upright item markers:

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{enumitem}
\newlist{thmlist}{enumerate}{1}
\setlist[thmlist]{label=\textup{(\roman{thmlisti})},ref={(\roman{thmlisti})}}
\makeatletter
\renewcommand{\p@thmlisti}{\perh@ps{\thethm}}
\protected\def\perh@ps#1#2{\textup{#1#2}}
\newcommand{\itemrefperh@ps}[2]{\textup{#2}}
\newcommand{\itemref}[1]{\begingroup\let\perh@ps\itemrefperh@ps\ref{#1}\endgroup}
\makeatother

\usepackage{hyperref}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\Crefname{thm}{Theorem}{Theorems}

\begin{document}

\section{A theorem}

\begin{thm}\label{theoremlabel}\mbox{}
\begin{thmlist}

\item\label{itemlabel} Something important.

\end{thmlist}
\end{thm}

Later on in my document... Isn't \Cref{theoremlabel} interesting?
I particularly like its clickable counter \ref{theoremlabel}
and \ref{itemlabel}.

\end{document}


Redefined some stuff, hyperlinks works, basically I reinvented the way John Kormylo did it (Please upvotes his answer there too!): How to change the appearance of \ref depending on where it's called relative to the \label

I've defined the requested \itemref, using the \getrefnumber from refcount package. With \StrBetween it's possible to search the item label between the parentheses: (i), for example.

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{xstring}
\usepackage{refcount}
\usepackage{enumitem}

\usepackage{hyperref}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\Crefname{thm}{Theorem}{Theorems}

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

\providecommand{\itemreffont}[1]{\textup{#1}}

\makeatletter
\newcommand{\itemref}[1]{%
\begingroup
\@ifundefined{r@#1}{\refused{#1}}{%
\edef\tempx{\detokenize\getrefnumber{#1}}%  Fetch the literal reference 1.1(i) (here)
\StrBetween{\tempx}{(}{)}[\@itemref]%  Get what's between the parantheses
}%
\endgroup
}
\makeatother

\usepackage{blindtext}
\begin{document}

\blindtext[10]

\section{A theorem}

\begin{thm}\label{theoremlabel}~
\begin{thmlist}

\item\label{itemlabel} Something important.

\item Something important about \itemref{itemlabel}. [Here's where I'd like to use my proposed \verb+\itemref{itemlabel}+ command.]

\end{thmlist}
\end{thm}

Later on in my document... Isn't \Cref{theoremlabel} interesting? I particularly like its clickable counter \ref{theoremlabel}.

\newpage