# Have something like figure but with its own counter and listof

Given the following MWE:

\documentclass[english]{scrartcl}

\usepackage{syntax}

\begin{document}

\begin{figure}
\begin{grammar}
<example> ::= $[ \lit{def} <identifier> \lit{=} <expr>$]
\end{grammar}
\caption{an example grammar}
\label{grm:example}
\end{figure}

\listoffigures

\end{document}


This draws me a nice (partial) definition of the non-terminal “example” in a fictive language and I can see it in the list of figures at the end. But in the real document there are also other figures, which should be in another listofwhatever.

So how can I define such environments by myself with the corresponding counters and lists?

edit

If it matters: I am using xelatex 3.1415926-2.5-0.9999.3-2013060708 (TeX Live 2013).

-
Have a look at the float package. –  Paul Gessler Jun 20 at 21:11

This functionality is offered by a number of packages: float, newfloat, and trivfloat for new floating objects.

Here's an example using newfloat (refer to the package documentation for the customization options it offers):

\documentclass[english]{scrartcl}
\usepackage{syntax}
\usepackage{newfloat}

\DeclareFloatingEnvironment{example}

\begin{document}

\begin{example}
\begin{grammar}
<example> ::= $[ \lit{def} <identifier> \lit{=} <expr>$]
\end{grammar}
\caption{an example grammar}
\label{grm:example}
\end{example}

\listofexamples

\end{document}


-