12

Say we have a huge document with many sections, subsections, and subsubsections. In a few of these sections, we have enumerated environments.

The package I am using is enumitem.

One of the environments could look like:

\begin{enumerate}
  \item \label{one}
  \item
\end{enumerate}
referring back to \cref{one}

Now if I reference this item later, it will say:

referring back to item 1

I could have other enumerated environments with \alph, (\alph), etc. and there reference could be item (a) or something.

The problem I have is what if I have another environment with the standard numbers that starts from 1 and goes to 4 but item 1 is also labeled. I would have another item 1 reference in the document. The hyperref would take it to a different list but is there a way to differentiate the printed out reference?

The list are unrelated so I don't want to start the new environment continuing the old numbering. Say starting from 3 and so on.

Here is a MWE:

\documentclass{article}
\usepackage{enumitem}
\usepackage{cleveref}
\begin{document}
\begin{enumerate}
  \item
    one \label{one}
  \item
    two \label{two}
\end{enumerate}
This \cref{two} is great.
\begin{enumerate}
  \item
    one \label{dog}
  \item
    two \label{cat}
\end{enumerate}
This \cref{cat} is a cat.
\end{document}

enter image description here

Would there be a way to change one of the references to observation 1 instead of item 1? This would be a local change nor global.

6

I would consider defining a new list

\newlist{observations}{enumerate}{10}
\setlist[observations]{label*=\arabic*}

and then tweaking crefname accordingly

\crefname{observationsi}{observation}{obvservations}
\Crefname{observationsi}{Observation}{Obvservations}

Here's the output

screenshot

and a complete MWE to play with

% arara: pdflatex
\documentclass{article}
\usepackage{enumitem}
\usepackage{cleveref}

\newlist{observations}{enumerate}{10}
\setlist[observations]{label*=\arabic*}

\crefname{observationsi}{observation}{obvservations}
\Crefname{observationsi}{Observation}{Obvservations}

\begin{document}
\begin{enumerate}
  \item
    one \label{one}
  \item
    two \label{two}
\end{enumerate}
This \cref{two} is great.
\begin{observations}
  \item one \label{dog}
  \item two \label{cat}
\end{observations}
This \cref{cat} is a cat.
\end{document}
9

Use enumitem's label and ref keys to yield a different printed label for each item or reference text when using \ref:

enter image description here

\documentclass{article}
\usepackage{enumitem,cleveref}% http://ctan.org/pkg/{enumitem,cleveref}
\begin{document}
\begin{enumerate}
  \item
    one \label{one}
  \item
    two \label{two}
\end{enumerate}
This \cref{two} is great.
\begin{enumerate}[ref={observation~\arabic*}]
  \item
    one \label{dog}
  \item
    two \label{cat}
\end{enumerate}
This \ref{cat} is a cat.
\end{document}
  • Do you know of any possible conflicts? I used this procedure and it printed out item observation 2. – dustin Aug 16 '13 at 22:42
  • @dustin: Note that I'm using \ref and not \cref. – Werner Aug 16 '13 at 22:43
  • How can we get \cref to work enumitem? – dustin Aug 16 '13 at 22:44
  • @dustin: cleveref provides \labelcref which does the same as \ref. Are you after using a regular \cref that produces item X in one instance, but observation Y in another? – Werner Aug 16 '13 at 23:01
  • I dont quite understand your question but cmhughes was able to solve the problem by creating a new list. – dustin Aug 16 '13 at 23:06

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.