3

With some help (by google) I was able to come up with a code allowing me to cross-reference enumerated items in amsthm-type enviroments via hyperref. The links and code work, but the hyperref link takes me directly to the referenced item (as intended by hyperref).

What I want to achieve is for hyperref to bring the screen to the Lemma itself and not to item (i), as the Lemma most of the time has a description which is important for all the items.

To see this interaction I was forced to put in some spacing. So sorry for the bunch of blindtext.

You might now ask why the trouble with cleveref at all. Because I will need to relabel Lemmas into Propositions or theorems or add in more items during my work process and I want the references to update automatically.

Thank you in advance.

Best regards Bob

    \documentclass[a4paper,12pt]{amsart}
    \usepackage[utf8]{inputenc}

    \usepackage{nameref,hyperref}
    \hyperbaseurl{.}
    \usepackage[capitalize,nameinlink]{cleveref}
    \usepackage{enumitem}

    \usepackage{amsmath,amscd,amssymb,amsfonts,amsthm}
    \usepackage{thmtools}   

    \newtheorem{theorem}{Theorem}[section]
    \newtheorem{lemma}[theorem]{Lemma}    


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

    \Crefname{lemma}{Lemma}{Lemmas}
    \addtotheorempostheadhook[lemma]{\crefalias{lemlisti}{lemma}}

\usepackage{blindtext}

\begin{document}
\blindtext[2]

\begin{lemma} 
Some important description for something and something else
\begin{lemlist}
  \item \label{1} something
  \item \label{2} something else
\end{lemlist} 
\end{lemma}

\blindtext[2]

\cref{1}

\end{document}
  • Welcome to TeX.SE. – Mico Jul 13 at 11:13
3

You need two labels for this, one for the number and one for the destination. You can then use \hyperref to setup the link.

\documentclass[a4paper,12pt]{amsart}
    \usepackage[utf8]{inputenc}

    \usepackage{nameref,hyperref}
    \hyperbaseurl{.}
    \usepackage[capitalize]{cleveref}
    \usepackage{enumitem}

    \usepackage{amsmath,amscd,amssymb,amsfonts,amsthm}
    \usepackage{thmtools}

    \newtheorem{theorem}{Theorem}[section]
    \newtheorem{lemma}[theorem]{Lemma}


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

    \Crefname{lemma}{Lemma}{Lemmas}
    \addtotheorempostheadhook[lemma]{\crefalias{lemlisti}{lemma}}

\usepackage{blindtext}
\begin{document}
\blindtext[2]


\begin{lemma}\label{main}
some important discription for something and something else
\begin{lemlist}
\item \label{1} something
\item \label{2} something else
\end{lemlist}
\end{lemma}
\blindtext[2]
\cref{1}

\hyperref[main]{\cref*{1}} or \namecref{1}~\hyperref[main]{\ref*{1}}
\end{document} 

enter image description here

  • The examples given by you work well, but do not give what I had in mind. I would prefer to find a somewhat "global approch". I should have stated that in my question. – Bobior Jul 13 at 15:25
  • well a global approach would need that you know the "parent" counter of your item (with some declaration/definition), that you store its value/destination name along with the label (possible e.g. with zref) and that you then make everything compatible with hyperref and cref (possible but not done in a few minutes). – Ulrike Fischer Jul 13 at 17:14
  • zref seems to provide what is needed to acces the needed information. I do not have enough time at the moment to build an implementation. But in about two month I might try to build it that way. – Bobior Jul 14 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.