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.

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).

share|improve this question
    
Have a look at the float package. –  Paul Gessler Jun 20 at 21:11

1 Answer 1

up vote 5 down vote accepted

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}

enter image description here

share|improve this answer

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.