Text FormattingCaption for an itemized List

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Pixer75
Posts: 13
Joined: Tue Mar 15, 2011 3:26 pm

Caption for an itemized List

Post by Pixer75 »

Hi,

I need to put a caption for a list of items (itemize environment). I found this macro on the web which seems to solve the issue:

Code: Select all

\makeatletter
\def\captionof#1#2{{\def\@captype{#1}#2}}
\makeatother
and then:

Code: Select all

\captionof{table}{\caption{un titre ici}\label{foo}}
However, the caption appears with the Table label at the front, followed by an automatically assigned number according to number of tables the document already has. I could also change "table" for "figure". But my lists aren't tables neither figures. I'd like something like "example" or "excerpt" to appear instead of "table" or "figure". I would also like to reset the counter. Is there a way of doing this?

Cheers!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Caption for an itemized List

Post by gmedina »

Hi,

with the help of the caption package you can easily define a new type of caption (and a new List associated with it, also). A little example:

Code: Select all

\documentclass{article}
\usepackage{caption}

\DeclareCaptionType{exam}[Example][List of Examples]

\begin{document}

\listofexams
\begin{enumerate}
  \item First item.
  \item Second item.
  \item Third item.
\captionof{exam}{This is a very important list.}
\end{enumerate}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Pixer75
Posts: 13
Joined: Tue Mar 15, 2011 3:26 pm

Re: Caption for an itemized List

Post by Pixer75 »

Thank you so much. It works brilliantly.
:-)
Post Reply