8

When I have a list such as

\begin{enumerate}
% List contents here...
\end{enumerate}

Or

\begin{itemize}
% List contents here...
\end{itemize}

How can I caption it, eg. as "List 1.1"? I could put it inside a table environment, but then the caption would say "Table 1.1", and this isn't a table.

4
  • 1
    do you want the environment to float?
    – cmhughes
    May 27 '14 at 2:25
  • @cmhughes No, but I'd prefer to have an answer for either option.
    – Superbest
    May 27 '14 at 3:46
  • 1
    ok, I'll update my answer later today
    – cmhughes
    May 27 '14 at 16:18
  • I've updated my answer to include a non-floating example at the end
    – cmhughes
    May 28 '14 at 4:10
13

Here's one way that you can do it using the newfloat package.

Notice that it is completely compatible with the caption and hyperref package, and that it provides the command

\listofmyfloats

to give a list of your floats.

% arara: pdflatex
\documentclass{article}
\usepackage{newfloat}
\usepackage{caption}
\DeclareFloatingEnvironment[fileext=cmh,placement={!ht},name=List]{myfloat}

\captionsetup[myfloat]{labelfont=bf}
\usepackage{lipsum}
\usepackage[colorlinks=true]{hyperref}

\newenvironment{listenv}[1]
    {\begin{myfloat}[tb]
      \begin{enumerate}
    \caption{#1}
    }
    {\end{enumerate}\end{myfloat}
    }

\begin{document}

\listofmyfloats
\begin{listenv}{More details}\label{list1}
\item one
\item two
\item three
\end{listenv}

See list \ref{list1} or figure \ref{fig1}.

\begin{figure}
\caption{A real figure}\label{fig1}
\end{figure}

\end{document} 

If you want a non-floating version, you can tweak this to, for example,

\newenvironment{nonfloatlistenv}[1]{%
    \center
    \captionof{myfloat}{#1}
    \enumerate
}
{\endenumerate\endcenter}

and then

\begin{nonfloatlistenv}{Non floating}\label{list1}
    \item one
    \item two
    \item three
\end{nonfloatlistenv}

Tweak this how you see fit.

3
  • The demonstration looks quite complex, could you please explain the different parts and add some comments?
    – Superbest
    Jun 2 '14 at 20:50
  • Also, this labels my lists incorrectly. I expect my lists in section n to be labeled List n.1, List n.2, and so on. Your MWE labels it List 1 no matter how many sections I add.
    – Superbest
    Jun 2 '14 at 20:59
  • @Superbest sounds like you want to use the \numberwithin command
    – cmhughes
    Jun 2 '14 at 23:29

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.