How can I reference item (i) in Theorem 1.1 such that it displays “Theorem 1.1-(i)”?

Consider the following example:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath, amsthm, amssymb, mathtools, thmtools}
\usepackage{hyperref, cleveref}
\usepackage[shortlabels]{enumitem}

\declaretheorem[numberwithin = section]{theorem}

\numberwithin{equation}{section}

\begin{document}

\begin{theorem}\label{foo}
\begin{enumerate}[(i)]
\item\label{bar}
\end{enumerate}
\end{theorem}

\end{document}


I want to obtain a reference to the item labeled "bar" in the theorem labeled "foo". The reference should display as "Theorem 1.1-i". How can I do this? If I use \autoref{foo} I only obtain "Theorem 1.1" and if I use \autoref{bar} I obtain "item (i)".

• \autoref{foo}-\ref{bar} – ferahfeza Apr 19 at 17:37
• @ferahfeza I've tried that before but this produces some space between "Theorem 1.1-" and "(i)". – 0xbadf00d Apr 19 at 17:58
• Look at may answer. There is no spaces, I think. – ferahfeza Apr 19 at 18:02

Like this? Use \autoref{foo}-\ref{bar}.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath, amsthm, amssymb, mathtools, thmtools}
\usepackage{hyperref, cleveref}
\usepackage[shortlabels]{enumitem}

\newtheorem{theorem}{Theorem}

%\numberwithin{equation}{section}

\begin{document}

\begin{theorem}\label{foo}
Lorem ipsum...
\begin{enumerate}[(i)]
\item\label{bar1}
\item\label{bar2}
\item\label{bar3}
\end{enumerate}
\end{theorem}
In \autoref{foo}-\ref{bar1} and in \autoref{foo}-\ref{bar2} and in \autoref{foo}-\ref{bar3} \ldots
\end{document}


Since you're using the enumitem package, you might as well use its \newlist/\setlist machinery to create a bespoke enumerate-like environment, called thmenum} in the code below, and use in theorem environments.

If you would like to change the prefix from "theorem item" to just "theorem", just replace \crefname{thmenumi}{theorem item}{theorem items} with \crefname{thmenumi}{theorem}{theorems}.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsthm, amssymb, mathtools, thmtools}
\declaretheorem[numberwithin = section]{theorem}

\usepackage[shortlabels]{enumitem}
\newlist{thmenum}{enumerate}{1} % to be used only inside 'theorem' environments
ref=\thetheorem-\textup{(\roman*)}}
\usepackage{cleveref}

\begin{document}
\setcounter{section}{2}  % just for this example
\begin{theorem}\label{foo}
\item\label{bar} Bla bla bla
\item\label{bor} Blo blo blo
\end{theorem}

\cref{bar}

\cref{bor,bar}
\end{document}

• Addendum - I honestly don't think the OP's desired formatting is all that good. When cross-referencing enumerated items in a theorem (or proposition, or whatever), one should just refer to them as "items (i) and (ii) in Theorem 1" and not "Theorems 1-(i) and 1-(ii)". However, that's clearly the OP's choice to make, not mine. – Mico Apr 19 at 18:13
• If I want to use "item (i) and (ii) of Theorem 1.1" at some other point, can we still achieve this? – 0xbadf00d Apr 19 at 18:16
• @0xbadf00d - Yes. Just delete the string ref=\thetheorem-\textup{(\roman*)} from the \setlist instruction, and change \crefname{thmenumi}{theorem item}{theorem items} to \crefname{thmenumi}{item}{items}. – Mico Apr 19 at 18:20

You can use the ref key, defined by znumitem.

Unrelated: needless to load amsmath if you load mathtools: the latter does it for you.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm, amssymb, mathtools, thmtools}
\usepackage{hyperref, cleveref}
\usepackage[shortlabels]{enumitem}

\declaretheorem[numberwithin = section]{theorem}

\numberwithin{equation}{section}

\begin{document}

\setcounter{section}{1}
\begin{theorem}\label{foo}
\begin{enumerate}[(i),ref =\cref{foo}-\roman*]
\item\label{bar} Really?
\end{enumerate}
\end{theorem}

We see in \ref{bar}

\end{document}
`