Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to create a simple enumeration and give it a label so I can access it. But the only thing I get in return is the number of the subsubsection. This is my code, which doesn't seem to work.

\begin{enumerate}
\label{eq_prm_1}

    \item bla
    \item moreBla

\end{enumerate}

Is it possible to encapsulate this piece in something that is referenceable?

share|improve this question
    
What do you expect to get? The enumerate doesnt have a caption, nor is it numbered, so what would you like a \ref to produce? –  Roelof Spijker Oct 21 '11 at 14:07
    
Yes I think you are right. I am looking for a way to simply number a list and create a caption underneath it and then reference to it. I thought that enumerate would be a good idea. –  Marnix Oct 21 '11 at 14:24
add comment

3 Answers 3

up vote 5 down vote accepted

It sounds as if what you want is like another kind of float, like a figure or table, except for it not necessarily to "float". Fortunately, the float package can do that for you.

\usepackage{float}   
\newfloat{lablist}{H}{lol}
\floatname{lablist}{List}

The above (in a preamble) defines a new floating environment, lablist, which is by default always placed exactly where it occurs in the source text (which is what the H does), and which are labelled by List n: in the captions. You can then do whatever you want in those environments, such as use an enumerated list.

Example.

\documentclass{article}

\usepackage{multicol}
\usepackage{float}
\newfloat{lablist}{H}{lol}
\floatname{lablist}{List}

\begin{document}

The following are the names of the digits in the Indo-Arabic numeral system, in English:
\begin{lablist}
  \setlength\columnseprule{0.3pt}
  \begin{multicols}{5}
  \begin{enumerate}
    \addtocounter{enumi}{-1}
    \item zero  \item one  \item two    \item three  \item four
    \item five  \item six  \item seven  \item eight  \item nine
  \end{enumerate}
  \end{multicols}
  \caption{foo}
  \label{list:foo}
\end{lablist}
\noindent
Refer to List~\ref{list:foo} whenever confused about the English names of numerals.

\end{document}

Sample list environment

share|improve this answer
    
Yes, it seems that this is what I am looking for! –  Marnix Oct 21 '11 at 16:26
add comment

You could encapsulate it in another enumerate environment:

\begin{enumerate}
\item \label{eq_prm_1}
  \begin{enumerate}
  \item bla
  \item moreBla
  \end{enumerate}
\end{enumerate}

To make it more sophisticated you should style the outer enumerate so that it's label looks different and so that it's label is counted up every time it's used. This can be done with the package enumitem. It's often encouraged to use semantic commands and therefore we define a environment based off of enumerate which we call refenum (for enumerated references) and stick every list we want to reference into that environment.

\documentclass{article}

\usepackage{enumitem}
\usepackage{blindtext}

\newlist{refenum}{enumerate}{1}
\setlist[refenum]{label=(\arabic*),resume}

\usepackage{enumerate}

\begin{document}

\blindtext[1]
\begin{refenum}
\item \label{eq_prm_1}
  \begin{enumerate}
  \item bla
  \item more bla
  \end{enumerate}
\end{refenum}
\blindtext[1]
\begin{refenum}
\item \label{eq_prm_2}
  \begin{enumerate}
  \item bla
  \item more bla
  \end{enumerate}
\end{refenum}
Compare list~\ref{eq_prm_1} and~\ref{eq_prm_2}.

\end{document}

The output of the sophisticated example

share|improve this answer
    
Yes, this does indeed solve what I mentioned in my question, but it does not solve what I am looking for. See my comment underneath my question to see what I am looking for, but I will need to accept your answer. –  Marnix Oct 21 '11 at 14:25
add comment

With my comment and your comment to that in mind as well as your original question, I suggest you take a look at the float package. It allows you to create a new float with caption to wrap your enumerate in.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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